Add this subroutine to the module:
sub DESTROY {
my ($self) = @_;
# Finish off our statement handle, so we don't get warnings like:
# DBI::db->disconnect invalidates 1 active statement handle
my $sth = $self->{data_handle};
if (blessed($sth) && $sth->can('finish')) {
$sth->finish;
}
}
A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.
Jump to
Perl: Fix DBI::db->disconnect invalidates 1 active statement handle
Labels:
databases,
mysql,
oo,
perl,
subroutines