|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-12-04 17:59 UTC] ssufficool@php.net
[2011-12-05 09:58 UTC] armiksos at gmail dot com
[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
[2020-02-03 08:24 UTC] cmb@php.net
-Status: Open
+Status: Verified
-PHP Version: 5.3.8
+PHP Version: 7.3
[2020-12-09 15:40 UTC] nikic@php.net
-Status: Verified
+Status: Duplicate
[2020-12-09 15:40 UTC] nikic@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 02:00:01 2025 UTC |
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 ) )