1 2 3 4 5 6
&mysql_connect($db) my $sqlStatement = "SELECT row FROM ... "; my $dbh = $db->prepare($sqlStatement); $dbh->execute(); my $row = $dbh->fetchrow_array(); &mysql_disconnect($db)
$dbh->finish;
if ($dbh) {$dbh -> finish;}
my $row = $dbh->fetchrow_array();
1
2
3
4
5
[Fri Apr 27 11:22:50 2012] [error] [client XXXXXXXX] -> disconnect
[Fri Apr 27 11:22:50 2012] [error] [client XXXXXXXX] for DBD::mysql::db (DBI::db=HASH(0x2129a88)
[Fri Apr 27 11:22:50 2012] [error] [client XXXXXXXX] ~0x2129a40
[Fri Apr 27 11:22:50 2012] [error] [client XXXXXXXX] ) thr#15e2010
[Fri Apr 27 11:22:50 2012] [error] [client XXXXXXXX] [Fri Apr 27 11:22:50 2012] xxxxx.pl: DBI::db=HASH(0x2129a40)->disconnect invalidates 1 active statement handle (either destroy statement handles or call finish on them before disconnecting) at ...
1 2 3 4
sub mysql_connect { %attr = (); my $db = DBI -> connect("DBI:mysql:mysql_compression=1:$databasename:$dbserver:$dbport", "$dbusername", "$dbpassword", \%attr); return $db;
1 2 3 4
sub mysql_disconnect { if ($dbh) {$dbh -> finish;} defined $_[0] and ($_[0]->disconnect or die "Keine Verbindung zur MySQL-Datenbank möglich - Grund: $DBI::errstr" and undef $_[0]); }
&mysql_connect($db)
1 2 3 4
sub mysql_connect { %attr = (); my $db = DBI -> connect("DBI:mysql:mysql_compression=1:$databasename:$dbserver:$dbport", "$dbusername", "$dbpassword", \%attr); return $db;