On Mar 16, 2007, at 1:12 PM, Randal L. Schwartz wrote: > package My::RDBO; > use base Rose::DB::Object; > use strict; > > sub init_db { > our $cached_db ||= do { > require My::RDB; # my Rose::DB subclass > My::RDB->new; > } > } > > 1;
mine relies heavily on external code that I can't strip down right now for clarity. i ommitted a lot, but you can get the idea of my setup the db switch code is rather painful to look at right now , but basically its just fetching a dbh from the factory, and tossing it into the rose::db object i chose to overwrite the dbh and not the db so i can keep invalid connect args as the rose::db default. i just get worried about objects not cleaning up, and this alleviates that concern. the chances of this being necessary -- .0000001%, but i don't want to risk any issues with a contamination of dbh handles =================== package My::RoseDB::Object ; # rose subclass. all my objects inherit. sub init_db { my $rdb_obj= My::RoseDB->new(); my $dbh= & My::DbFactory::getDB_reader( 'DBH'=> 1); $rdb_obj->dbh( $dbh ); return $rdb_obj; }; 1; package My::DbFactory; # factory class. connects & caches a read/write/logger/config handle. my $DB_reader= My::DbFactory::Reader->new(); sub getDB_reader { my ( %kw_args )= @_; return $DB_reader->dbh if ( defined $kw_args{'DBH'} && int($kw_args {'DBH'}) ); return $DB_reader; } 1; package My::DbFactory::Reader ; our @ISA= qw( P_2XLP::DB ); # db instance # version of P_2XLP::DB , which is like the DBIx::Transaction by Tyler MacDonald my %_db_config= (); Apache::DBI->connect_on_init(); ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object