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: 2014-01-01 12:41 UTC
From: armiksos at gmail dot com Assigned:
Status: Open Package: PDO MySQL
PHP Version: 5.3.8 OS: windows 7
Private report: No CVE-ID:
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
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Wed Apr 26 11:01:42 2017 UTC