php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36228 Loosing connection to db while executing 2 Multi-Statements requests with PDO
Submitted: 2006-01-31 15:12 UTC Modified: 2006-05-06 15:27 UTC
Votes:5
Avg. Score:4.0 ± 1.3
Reproduced:4 of 4 (100.0%)
Same Version:3 (75.0%)
Same OS:3 (75.0%)
From: antleclercq at online dot fr Assigned: wez (profile)
Status: Not a bug Package: PDO related
PHP Version: 5.1.2 OS: Ubuntu Linux (breezy)
Private report: No CVE-ID: None
 [2006-01-31 15:12 UTC] antleclercq at online dot fr
Description:
------------
Hello,

Executing 2 multi-statement queries gives you the following error : 
2013 - Lost connection to MySQL server during query

I reproduced this error using 5.1.0RC3 and 5.1.2.

My MySQL version is 4.1.12, and I have the right MySQL / PDO connector.

Thanks,

Antoine

Reproduce code:
---------------
<?php
$dbh = new PDO("mysql:dbname=karibou;host=localhost", "user", "password");
try {
  	$qry  = "DELETE FROM addressbook_address WHERE profile_id=2 ; \n";
	$qry .= "DELETE FROM addressbook_phone WHERE profile_id=2 ; \n";
	
	//No error
	$dbh->exec($qry);
	//The folowing line displays : Array ( [0] => 00000 )
	print_r($dbh->errorInfo());

	//This second exec statement produces the error : "Lost connection to MySQL server during query"
	$dbh->exec($qry);
	//The following line displays : Array ( [0] => HY000 [1] => 2013 [2] => Lost connection to MySQL server during query )
   print_r($dbh->errorInfo());
   
} catch (PDOException $e) {
   print $e->getMessage();
   die();
}

?>

Expected result:
----------------
None of the exec should return an error.

Actual result:
--------------
The second exec returns a 2013 error (Lost connection...).

Array ( [0] => HY000 [1] => 2013 [2] => Lost connection to MySQL server during query )

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-01-31 15:55 UTC] tony2001@php.net
Just curious: what do you expect to get as the result of these multi-statement?
PDO::exec returns number of rows expected. Since you're effectively executing two queries - what do you expect to get?
What if one of the queries succeeds and another one fails?
 [2006-01-31 17:03 UTC] antleclercq at online dot fr
Hello Tony,

It looks like it returns only the number of affected rows for the first statement...
The affected rows for the next statements don't seem to be counted.

Also : if you have an error in your first statement, you get an error, but if the error is in one of the next statements, these are not reported.

Hmmm... I don't know really what I would expect to get as return value from a multi-query... Certainly a sum of all the affected rows or better... an array with that info on each statement.

Antoine
 [2006-03-01 12:57 UTC] antleclercq at online dot fr
Hi,

Any update ?

Thanks,

Antoine
 [2006-04-30 01:01 UTC] wez@php.net
If you're executing multi-statement queries, you must use PDO::prepare(), PDOStatement::execute() and PDOStatement::nextRowset().
 [2006-05-06 15:27 UTC] antleclercq at online dot fr
Thanks for your answer, but could you please post the way you would execute those 2 queries ?
Thanks in advance,

Antoine
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 09:01:28 2024 UTC