Menu

#100 isConnected

Benchmark
open
5
2009-11-26
2009-11-26
No

There is another issue on the isconnected function.

Before running the query, I run isConnected function to check if the connection is still alive (since my server drops connection in 10 minutes -- wait_timeout), and when I call the function it returns TRUE (which makes the script believes that it is still conected when its not).

I made a simple test, with this code:
-
$db = ADONewConnection('mysql');
$db->PConnect(dbHost, dbUser, dbPass, dbName);
$db->debug = true;

$db->Execute("SELECT NOW()");

for($i=1;$i<=10;$i++)
{
sleep(1);
echo ".";
}

print_r($db->IsConnected());
if(!$db->IsConnected()) $db->Connect(dbHost, dbUser, dbPass, dbName);
$db->Execute("SELECT NOW()");
-

And got this result:
(mysql): SELECT NOW()
-----
2006: MySQL server has gone away

In this case, I connected to mysql and killed the session within 5 seconds. When it tried to run another query the connection was gone and it said that it was still connected.

Thanks!
Rafael
[rafael [at] r2pro [dot] com [dt] br

Discussion


Log in to post a comment.

MongoDB Logo MongoDB