On Tue, 10 Feb 2004 18:10:42 -0500, Andrew Pimlott wrote:
>Is there any way to prevent the following from warning "Issuing
>rollback() for database handle being DESTROY'd without explicit
>disconnect()."?
>
> use DBI;
>
> my $dbh = DBI->connect('dbi:Pg:dbname=...', undef, undef,
> { RaiseError => 1, AutoCommit => 0 });
> $dbh->commit();
You can do an explicit disconnect().
In many cases, you can just do that without thinking about it, by doing
it like this:
END {
$dbh->disconnect if $dbh;
}
which also does its job in case of a die().
Without testing, I doubt that this will work satisfactorily in mod_perl
and similar setups.
--
Bart.