MySQL Error "Gone Away" with persistent PHP connection

I host the site locally on the WAMP stack. I recently switched the PHP connection to persistence by adding a array(PDO::ATTR_PERSISTENT => true)constructor to the options argument PDO. As a result, I noticed that the result was a significant reduction in response time (hurray!).

It seems that the missing error occurs when the machine wakes up. This never happened before changing the connection style.

Is it possible that the cached connection is closed but keeps returning? Is it possible to reset a connection PDOor reset the connection pool through the PHPinside of the catch block?

+4
source share
2 answers

, , -, PDO, .

:

  • PHP 5.4.22
  • php.ini .
  • ( -1)
  • ( -1)

, :

MySQL.

set @@GLOBAL.interactive_timeout := 10;
set @@GLOBAL.wait_timeout := 10;

. :

echo $conn->getAttribute(PDO::ATTR_SERVER_INFO);

10 . "".

, SQL PDO , .

PDO . .

, ( , ), MySQL

set @@GLOBAL.interactive_timeout := 86400;

set @@GLOBAL.wait_timeout := 86400;

28800 (8 ). , Apache, , ( , ). 86400, 24 , , .

12 , , , "". , .

, , , , . , "", NULL, PHP . , ( ), .

+1

All Articles