Hi all.
Could anybody tell me how to setup and handle persistent connections 
using DBI::mysql?
I am not allowed to use Apache::DBI.
I tried:

sub Application_OnStart{
                $dbh = DBI->connect(
                "DBI:mysql:database=mydatabase","me","mypassword",
     {
      PrintError => 1, # warn( ) on errors
      RaiseError => 0, # don't die on error
      AutoCommit => 1, # commit executes immediately
     }

                )||     sub{$DBI::errstr;undef $dbh};
}

#and then

sub Application_OnEnd{
        sub{if($dbh){$dbh->disconnect} };
}

#A chek

sub check_connection_and_connect_if_needed{
 if (!$dbh){
                $dbh = DBI->connect(
                "DBI:mysql:database=f8","f8","qazwsx",
     {
      PrintError => 1, # warn( ) on errors
      RaiseError => 0, # don't die on error
      AutoCommit => 1, # commit executes immediately
     }

                )||     sub{$DBI::errstr;undef $dbh};
 }
}

sub Script_OnStart{

check_connection_and_connect_if_needed();
#.....
}

Where to put 

        $Server->RegisterCleanup(sub{if($dbh){$dbh->disconnect} });
if the server is restarted or killed

Is there a standart way
or som tweaking? 

Thank in advance.



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to