Bug #60122 [Com]: PDO_MYSQL: Many multi-row statements gives wrong result
| From: | sladkov at gmail dot com | Date: | Fri, 20 Apr 2018 15:14:23 +0000 |
| Subject: | Bug #60122 [Com]: PDO_MYSQL: Many multi-row statements gives wrong result | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-214815@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
Comment by: sladkov at gmail dot com
Reported by: armiksos at gmail dot com
Summary: PDO_MYSQL: Many multi-row statements gives wrong
result
Status: Open
Type: Bug
Package: PDO MySQL
Operating System: windows 7
PHP Version: 5.3.8
Block user comment: N
Private report: N
New Comment:
Still reproduces with PHP 7.1.15 + mysqlnd driver.
Although with PDO::MYSQL_ATTR_USE_BUFFERED_QUERY set to false it works as expected.
Previous Comments:
------------------------------------------------------------------------
[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