|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-10-30 20:44 UTC] Jared dot Williams1 at ntlworld dot com
Description:
------------
Calling a MySQL5.0.15 stored procedure twice causes
Warning: PDO::query() [function.query]: SQLSTATE[HY000]: General error: 2013 Lost connection to MySQL server during query in ...\pdotest.php on line 14
Reproduce code:
---------------
CREATE DATABASE pdotest;
DELIMITER $$
CREATE PROCEDURE `pdotest`.`spIsStringComparisonCaseInsensitive` ()
BEGIN
SELECT 'a' = 'A' AS isInsensitive;
END $$
DELIMITER ;
------
$pdo = new PDO('mysql:localhost;dbname=pdotest', 'root', '');
$pdo->setAttribute(PDO_ATTR_ERRMODE,PDO_ERRMODE_WARNING);
$stmt = $pdo->query('CALL pdotest.spIsStringComparisonCaseInsensitive()');
foreach($stmt as $row)
{
echo $row['isInsensitive'];
}
/* Line below causeing the warning */
$stmt2 = $pdo->query('CALL pdotest.spIsStringComparisonCaseInsensitive()');
foreach($stmt2 as $row)
{
echo $row['isInsensitive'];
}
Expected result:
----------------
print 1 twice, without a warning.
Actual result:
--------------
Print 1 followed by
Warning: PDO::query() [function.query]: SQLSTATE[HY000]: General error: 2013 Lost connection to MySQL server during query in ...\pdotest.php on line 14
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 12:00:01 2025 UTC |
Doesn't fix it. Updated code, for PHP5.1RC5-dev <?php $pdo = new PDO('mysql:localhost;dbname=pdotest', 'root', ''); $pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_WARNING); $stmt = $pdo->query('CALL pdotest.spIsStringComparisonCaseInsensitive()'); foreach($stmt as $row) { echo $row['isInsenstive']; } $stmt = NULL; /* Line below causeing the warning */ $stmt2 = $pdo->query('CALL pdotest.spIsStringComparisonCaseInsensitive()'); foreach($stmt2 as $row) { echo $row['isInsenstive']; } ?> Also tried this with mysqli, seem to suffer from the same problem.Me too...in a different case. I am using persistent PDO connetions and I get the same error message but with some differences: 1) I only get the error randomly (approx. every 20th call of the script) and when there is high load on the server. 2) I get the error in the prepare statement, not in the execute statement 3) nextRowset and closeCursor does not change anything. My present workaround is not to use persistent PDO connections - then the code works fine. Thus, I guess the error is somewhere inside of the connection pooling code of PDO. Here my stuff: try { $selectDBH = new PDO('mysql:host='.$host.';dbname='.$db, $selectuser, $selectpass, array(PDO::ATTR_PERSISTENT => true)); $selectDBH->setAttribute (PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sth = NULL; $sth = $selectDBH->prepare('SELECT COUNT(1) FROM NOTES WHERE RKEY=?'); $sth->execute(array($locationP)); $resuNumP = $sth->fetchAll(PDO::FETCH_NUM); do {} while ($sth->nextRowset()); $sth->closeCursor();