in reply to Re^3: Singletons, Apache::DBI and MySQL
in thread Singletons, Apache::DBI and MySQL

Nope, we totally rewrote it... Not using Apache::DBI anymore...
package DBH; use strict; use Init; use DBI (); sub connect { if (defined $DBH::conn) {#die ref( $DBH::conn); my $ret; eval { $ret = DBH->ping; }; if (!$@ && $ret) { return $DBH::conn; } } $debug && print STDERR "DBH.pm: making new connection\n"; $DBH::conn = DBI->connect( "DBI:mysql:blah, { PrintError => 1, RaiseError => 0, } ) || die $DBI::errstr; #Assume application handles this return $DBH::conn; } sub ping { my $ret = 0; if (time - $DBI::lastPing < 10) { return 1; } eval { local $SIG{__DIE__} = sub { return (0); }; local $SIG{__WARN__} = sub { return (0); }; # adapt the select statement to your database: $ret = $DBH::conn->do('select 1'); $DBI::lastPing = time; #record time in seconds }; $debug && print STDERR "DBH.pm: pinging DB handle: $ret\n"; return ($@) ? 0 : $ret; }