Edit report at https://bugs.php.net/bug.php?id=61207&edit=1

 ID:                 61207
 User updated by:    acabal at ucla dot edu
 Reported by:        acabal at ucla dot edu
 Summary:            PDO::nextRowset() after a multi-statement query
                     doesn't always work
 Status:             Open
 Type:               Bug
 Package:            PDO related
 Operating System:   Ubuntu 11.10 64-bit
 PHP Version:        5.4.0RC8
 Block user comment: N
 Private report:     N

 New Comment:

Oops, a small typo in the linked example script: In the bugged example, I typed 
$handle1 instead of $handle4 in the do loop.  Interestingly the script still 
produces the same bugged output even with the typo.


Previous Comments:
------------------------------------------------------------------------
[2012-02-29 05:45:49] 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


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=61207&edit=1

Reply via email to