On 4/19/07, Bill Moseley <[EMAIL PROTECTED]> wrote:
> On Thu, Apr 19, 2007 at 10:35:16AM -0400, John Siracusa wrote:
>> 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?
>>
> Yes. But, also one that supports pinging the database and creating a new
> handle if the connection is dropped.
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 think that'll do what you want: a new/refreshed $dbh every time,
with a single long-lived App::RDB object (which doesn't go out of
scope and therefore doesn't call disconnect() on its $dbh).
-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
[email protected]
https://lists.sourceforge.net/lists/listinfo/rose-db-object