On Thu, Apr 19, 2007 at 02:48:24PM -0400, John Siracusa wrote:
> Okay, so:
>
> our $DB;
>
> sub init_db
> {
> ...
> my $dbh = DBI->connect_cached(@params);
> return $DB = App::RDB->new(dbh => $dbh) unless($DB);
> $DB->dbh($dbh);
> return $DB;
> }
I'm still seeing disconnect called in the DBI_TRACE output.
I'll get a better test script when I'm back at my office but this is
what I'm using (as above):
our $DB;
sub init_db {
my $self = shift;
# Fetch cached dbh, possibly a new dbh
# if ping fails
my $dbh = $self->_get_dbh;
# If there's already a Rose::DB object just
# update its dbh handle and return
if ( $DB ) {
$DB->dbh( $dbh );
return $DB;
}
warn "creating new object\n";
# Otherwise, create a new database object.
return $DB = iPDemo::RDB->new(dbh => $dbh);
}
$ perl test_rdbo.pl
creating new object
---- Fetch all rows ----
id=1 Full name 'Initial User' dbh = DBI::db=HASH(0x8ddfbd4)
id=2 Full name 'Bill moseley' dbh = DBI::db=HASH(0x8ddfbd4)
id=4 Full name 'Bill Moseley3' dbh = DBI::db=HASH(0x8ddfbd4)
id=3 Full name 'Bill Moseley' dbh = DBI::db=HASH(0x8ddfbd4)
--- Fetch all rows ----
id=1 Full name 'Initial User' dbh=DBI::db=HASH(0x8f59bb0)
id=2 Full name 'Bill moseley' dbh=DBI::db=HASH(0x8f59bb0)
id=4 Full name 'Bill Moseley3' dbh=DBI::db=HASH(0x8f59bb0)
id=3 Full name 'Bill Moseley' dbh=DBI::db=HASH(0x8f59bb0)
---- Fetch single row ---
first_name Bill
dbh = DBI::db=HASH(0x8f59148)
---- Fetch many to many relation ----
Role Admin
Role dbh = DBI::db=HASH(0x8f59148)
Role ReportAdmin
Role dbh = DBI::db=HASH(0x8f59148)
$ DBI_TRACE=1 perl test_rdbo.pl 2>&1 | grep disconnect
<- disconnect= 1 at DB.pm line 769
<- disconnect= 1 at DB.pm line 769
<- disconnect= 1 at DB.pm line 769
<- disconnect_all= '' at DBI.pm line 700
--
Bill Moseley
[EMAIL PROTECTED]
-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/rose-db-object