|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-03-03 15:32 UTC] georg@php.net
[2006-03-04 09:42 UTC] nerve at gmx dot net
[2006-03-04 22:04 UTC] georg@php.net
[2006-03-04 23:56 UTC] nerve at gmx dot net
[2006-03-08 15:48 UTC] nerve at gmx dot net
[2006-03-08 15:54 UTC] nerve at gmx dot net
[2006-03-13 15:47 UTC] damien dot harper at gmail dot com
[2006-04-09 08:12 UTC] wez@php.net
[2016-03-04 11:35 UTC] source dot spider at gmail dot com
[2020-02-11 16:56 UTC] rgagnon24 at gmail dot com
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 10:00:01 2025 UTC |
Description: ------------ My Site connect with PDO and PDO::ATTR_PERSISTENT => true to MySQL. If the MySQL server is restarting or a tread of the Server is killed, the Apache tread wich is connected cant execute any statements until Apache was restartet. The PDO Connect return with succes, but the first query fails with "MySQL server has gone away". A MySQL Server restart was no problem with the old mysql_pconnect function. I want a detection on creation of new PDO object with persistent connection if the connection is alive or a method to close the old connection. I use php 5.1.2 with apache 2.0.55 on gentoo linux with mysql 5.0.18-log Please se my workaround code, witch make a fallback to slower non persistent object. Reproduce code: --------------- // Workaround code for problem with pdo and persistent connection try { $db = new PDO('mysql:host='.$db_host.';dbname='.$db_db, $db_user,$db_pw, array(PDO::ATTR_PERSISTENT => true)); $db->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); $db_info = $db->getAttribute(PDO::ATTR_SERVER_INFO); // erkennung von toten persistenten verbindungen ... if($db_info == "MySQL server has gone away") { $db = null; $db = new PDO('mysql:host='.$db_host.';dbname='.$db_db, $db_user,$db_pw); } }catch (PDOException $e) { print "Fehler in der DB Verbindung!: " . $e->getMessage() . "<br/>"; $db = null; die(); } Expected result: ---------------- alive persistent connection if mysql is running ! Actual result: -------------- dead mysql persistent connection if mysql was restartet !!!