|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-02-29 05:45 UTC] acabal at ucla dot edu
Description: ------------ After executing a single multi-statement query in PDO in which the statements are INSERT, followed by UPDATE, followed by SELECT, then trying to loop over the results using PDO::nextRowset(), the function returns FALSE (i.e. no more rowsets) after the UPDATE rowset, but before reaching the SELECT rowset. Thus the SELECT rowset is lost. I tried several permutations of multi-statement queries. INSERT, then SELECT, then UPDATE works; SELECT then UPDATE works; UPDATE then SELECT works; only INSERT, then UPDATE, then SELECT fails. See the below code for those examples plus the bugged example. I originally ran in to this problem on PHP 5.3.5, but it still appears in PHP 5.4.0RC8. Test script: --------------- First create the following MySQL test db/table: create database `test`character set utf8 collate utf8_general_ci; create table `test`.`testtable`( `id` int ); Next check this example code to see the bug in action. There are four examples in the code, the first three work, and the last one is the bug. http://pastebin.com/EKePD6e2 The bug tracker suggested a link for code longer than 20 lines, though I can provide the example script directly in this bug report if that would be helpful. Expected result: ---------------- Handle 1: Rowset 1 Rowset 2 Results detected Handle 2: Rowset 1 Results detected Handle 3: Rowset 1 Rowset 2 Results detected Handle 4: Rowset 1 Rowset 2 Results detected Actual result: -------------- Handle 1: Rowset 1 Rowset 2 Results detected Handle 2: Rowset 1 Results detected Handle 3: Rowset 1 Rowset 2 Results detected Handle 4: Rowset 1 Patchesbug61207.diff (last revision 2012-02-29 12:21 UTC by johannes@php.net)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 22:00:01 2025 UTC |
$statement = $connection->query($sql_multiquery); //check for errors do { } while ($statement->nextRowset()); I noticed that $statement->nextRowset() closes the current transaction, so if something went wrong you can't rollBack