I am not sure we should add all this overhead to the thin DBI layer, that is
what the abstraction layers for DBI are for. We might be able to have this
option if we can turn it on and off, possibly again without creating any
overhead.
Ilya
-----Original Message-----
From: Terrence Brannon
To: [EMAIL PROTECTED]
Sent: 1/11/02 7:39 AM
Subject: should DBI have a "KeepAlive" attribute
in Example::DB in DBIx::AnyDBD, we see code which always returns
a viable database handle or throws an exception. The question is
shouldn't this type of behavior be available as part of DBI?
sub instance {
if ($DB && $DB->ping) {
# rollback uncommited transactions
# this doesn't work where multiple nested method calls
might call insta\
nce()
# $DB->rollback;
return $DB;
}
my $class = shift;
my $x = 0;
do {
if ($DB) {
eval { $DB->disconnect; };
undef $DB;
}
$class->connect;
return $DB if $DB && $DB->ping
} until ($x++ > MAX_ATTEMPTS);
die "Couldn't connect to database";
}