Bug #60122 [Opn->Ver]: PDO_MYSQL: Many multi-row statements gives wrong result
| From: | cmb@php.net | Date: | Mon, 03 Feb 2020 08:24:07 +0000 |
| Subject: | Bug #60122 [Opn->Ver]: PDO_MYSQL: Many multi-row statements gives wrong result | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-225321@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=60122&edit=1
ID: 60122
Updated by: cmb@php.net
Reported by: armiksos at gmail dot com
Summary: PDO_MYSQL: Many multi-row statements gives wrong
result
-Status: Open
+Status: Verified
Type: Bug
Package: PDO MySQL
Operating System: windows 7
-PHP Version: 5.3.8
+PHP Version: 7.3
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2018-04-20 15:14:22] 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.
------------------------------------------------------------------------
[2011-12-05 09:58:20] armiksos at gmail dot com
I use MySQL driver.
------------------------------------------------------------------------
[2011-12-04 17:59:00] ssufficool@php.net
Which driver are you using (i.e. MySQL, PostgreSQL, DBLIB, SqlServer?)
------------------------------------------------------------------------
[2011-10-24 14:49:39] 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 ) )
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60122&edit=1