On 04 Jan 2003 00:30:10 -0800 Ask Bjoern Hansen <[EMAIL PROTECTED]> wrote:

> 
> Without the extra ping (see the line following the XXX comment) this
> program fails on the second "select ..." with 
> 
> "DBD::mysql::db selectrow_array failed: Lost connection to MySQL server
> during query at dbitest line 19."
> 
> Why do I need to ping twice?
> 
> I am using perl 5.6.1, DBI 1.21 and DBD::mysql 2.1011.
> 
> I also tried upgrading DBI to 1.32 and DBD::mysql to 2.1022; but it
> didn't change anything.

I don't know a specific answer, but try breaking the task up and
adding trace() to see what DBI thinks is happening.

 # untested
 sub db_open {
   DBI->trace( 4, "trace.log" );
   ## XXX - add an extra ping so the second ping will work properly!
   # $dbh_cache and $dbh_cache -> ping;
   $dbh_cache = DBI -> connect( "dbi:mysql:cswwwdata;user=root" )
      unless $dbh_cache and $dbh_cache -> ping;
   DBI->trace( 0 );
   return $dbh_cache;
 }

> my $dbh_cache;
> sub db_open {
>   ## XXX - add an extra ping so the second ping will work properly!
>   #$dbh_cache and $dbh_cache->ping;
>   return $dbh_cache if $dbh_cache and $dbh_cache->ping;
>   return $dbh_cache = DBI->connect("dbi:mysql:cswwwdata;user=root")
> }

-- 
Mac :})
** I normally forward private questions to the appropriate mail list. **
Ask Smarter: http://www.tuxedo.org/~esr/faqs/smart-questions.html
Give a hobbit a fish and he eats fish for a day.
Give a hobbit a ring and he eats fish for an age.

Reply via email to