use connect_cached so we will reconnect when mysql drops connection
authorDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 19 Apr 2010 13:48:35 +0000 (13:48 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 19 Apr 2010 13:48:35 +0000 (13:48 +0000)
lib/LDAP/Koha.pm

index b0c726c..540d278 100644 (file)
@@ -39,8 +39,6 @@ $SIG{__DIE__} = sub {
 
 require 'config.pl' if -e 'config.pl';
 
-my $dbh = DBI->connect($dsn . $database, $user,$passwd, { RaiseError => 1, AutoCommit => 1 }) || die $DBI::errstr;
-
 # we need reverse LDAP -> SQL mapping for where clause
 
 my $ldap_sql_mapping = {
@@ -208,6 +206,7 @@ sub search {
                        ;
 
                warn "# SQL:\n$sql\n# DATA: ",dump( @values );
+               my $dbh = DBI->connect_cached($dsn . $database, $user,$passwd, { RaiseError => 1, AutoCommit => 1 }) || die $DBI::errstr;
                my $sth = $dbh->prepare( $sql );
                $sth->execute( @values );