php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60122 PDO_MYSQL: Many multi-row statements gives wrong result
Submitted: 2011-10-24 14:49 UTC Modified: 2020-02-03 08:24 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: armiksos at gmail dot com Assigned:
Status: Verified Package: PDO MySQL
PHP Version: 7.3 OS: windows 7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: armiksos at gmail dot com
New email:
PHP Version: OS:

 

 [2011-10-24 14:49 UTC] armiksos at gmail dot com
Description:
------------
If you create two query of multi-row statements in one .php file and you assign 
them 
to the same variable after processing one of them, the second query will give only 
result of only ONE statement.

If you assign the result of query to another variable, the result will be correct.

So    $another_var_name = $conn->query("SELECT 1 as one; SELECT 2 as two; SELECT 3 
as three;");

will work in Test script, otherwise result will be wrong.

Test script:
---------------
               $q = $conn->query("SELECT 1 as one; SELECT 2 as two; SELECT 3 as three;");
           
                do
                {
                   $r=$q->fetchAll(PDO::FETCH_ASSOC);
                   echo "<br />";
                   print_r($r);       
                   
                }while($q->nextRowset());
                
           
               $q = $conn->query("SELECT 1 as one; SELECT 2 as two; SELECT 3 as three;");
           
                do
                {
                   $r=$q->fetchAll(PDO::FETCH_ASSOC);
                     echo "<br />";
                   print_r($r);       
                   
                }while($q->nextRowset());   

Expected result:
----------------
Array ( [0] => Array ( [one] => 1 ) )
Array ( [0] => Array ( [two] => 2 ) )
Array ( [0] => Array ( [three] => 3 ) )
Array ( [0] => Array ( [one] => 1 ) )
Array ( [0] => Array ( [two] => 2 ) )
Array ( [0] => Array ( [three] => 3 ) ) 

Actual result:
--------------
Array ( [0] => Array ( [one] => 1 ) )
Array ( [0] => Array ( [two] => 2 ) )
Array ( [0] => Array ( [three] => 3 ) )
Array ( [0] => Array ( [one] => 1 ) ) 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-12-04 17:59 UTC] ssufficool@php.net
Which driver are you using (i.e. MySQL, PostgreSQL, DBLIB, SqlServer?)
 [2011-12-05 09:58 UTC] armiksos at gmail dot com
I use MySQL driver.
 [2013-06-12 04:13 UTC] ssufficool@php.net
-Summary: Many multi-row statements gives wrong result +Summary: PDO_MYSQL: Many multi-row statements gives wrong result
 [2014-01-01 12:41 UTC] felipe@php.net
-Package: PDO related +Package: PDO MySQL
 [2018-04-20 15:14 UTC] sladkov at gmail dot com
Still reproduces with PHP 7.1.15 + mysqlnd driver.
Although with PDO::MYSQL_ATTR_USE_BUFFERED_QUERY set to false it works as expected.
 [2020-02-03 08:24 UTC] cmb@php.net
-Status: Open +Status: Verified -PHP Version: 5.3.8 +PHP Version: 7.3
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Aug 14 21:01:24 2020 UTC