in reply to Moose::Role to provide DBI interface
Hi nysus,
It's hard for me to imagine when you'd want to change the DB connection attribute of an object instance. If you really need more than one connection, it might be better to hide them in the consuming class behind object methods that simply return the data you want.
On the other hand it *is* common to need to connect to more than one DB in a given application. In that case (or in the case of a single object needing more than one connection) I would suggest using an external configuration file with the configs for your various DSNs, and then create your single class that will return a DB connection based on the parameters passed. I wouldn't try to switch connections as you've outlined, seems too error-susceptible and for no real benefit. Other monks may be able to provide the nitty-gritty as to why it's a bad idea; all I can say is that it smells dodgy.
Hope this helps!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Moose::Role to provide DBI interface
by nysus (Parson) on Feb 08, 2017 at 20:48 UTC | |
by Anonymous Monk on Feb 08, 2017 at 20:52 UTC | |
by nysus (Parson) on Feb 08, 2017 at 20:54 UTC | |
by Anonymous Monk on Feb 08, 2017 at 20:57 UTC |