On 4/18/07, Bill Moseley <[EMAIL PROTECTED]> wrote: > This works fine in my base class: > > sub init_db { our $DBH =|| App::RDB->new } > > I've got the same $dbh for the life of the program. > > But, I'd like to try using DBI->connect_cached directly.
What's your goal? Do you still want just one $dbh for the life of the program? > sub init_db { > ... > my $dbh = DBI->connect_cached( @params ); > return App::RDB->new( dbh => $dbh ); > } > > Where @params does not change between calls. I then get a new $dbh. > for new RDBO objects. > > So, I'm not seeing how to correctly do this. Shouldn't DBI->connect_cached return the same $dbh every time it's called? If so, then in the code above you're returning a new App::RDB object each time, but all those App::RDB objects are sharing a single $dbh. Is that not what you want? Here's another variant: our $DB; sub init_db { return $DB if($DB); ... my $dbh = DBI->connect_cached(@params); return $DB = App::RDB->new(dbh => $dbh); } Getting closer to what you want? -John ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object