1--TEST-- 2PDO MySQL Bug #61207 (PDO::nextRowset() after a multi-statement query doesn't always work) 3--SKIPIF-- 4<?php 5require_once(__DIR__ . DIRECTORY_SEPARATOR . 'skipif.inc'); 6require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); 7MySQLPDOTest::skip(); 8 9?> 10--FILE-- 11<?php 12require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); 13/** @var PDO $db */ 14$db = MySQLPDOTest::factory(); 15 16$db->query('DROP TABLE IF EXISTS test'); 17$db->query('create table `test`( `id` int )'); 18 19$handle1 = $db->prepare('insert into test(id) values(1); 20 select * from test where id = ?; 21 update test set id = 2 where id = ?;'); 22 23$handle1->bindValue(1, '1'); 24$handle1->bindValue(2, '1'); 25 26$handle1->execute(); 27$i = 1; 28print("Handle 1:\n"); 29do { 30 print('Rowset ' . $i++ . "\n"); 31 if ($handle1->columnCount() > 0) 32 print("Results detected\n"); 33} while($handle1->nextRowset()); 34 35$handle2 = $db->prepare('select * from test where id = ?; 36 update test set id = 1 where id = ?;'); 37 38$handle2->bindValue(1, '2'); 39$handle2->bindValue(2, '2'); 40 41$handle2->execute(); 42 43$i = 1; 44print("Handle 2:\n"); 45do { 46 print('Rowset ' . $i++ . "\n"); 47 if ($handle2->columnCount() > 0) 48 print("Results detected\n"); 49} while($handle2->nextRowset()); 50 51$handle3 = $db->prepare('update test set id = 2 where id = ?; 52 select * from test where id = ?;'); 53 54$handle3->bindValue(1, '1'); 55$handle3->bindValue(2, '2'); 56 57$handle3->execute(); 58 59$i = 1; 60print("Handle 3:\n"); 61do { 62 print('Rowset ' . $i++ . "\n"); 63 if ($handle3->columnCount() > 0) 64 print("Results detected\n"); 65} while($handle3->nextRowset()); 66 67$handle4 = $db->prepare('insert into test(id) values(3); 68 update test set id = 2 where id = ?; 69 select * from test where id = ?;'); 70 71$handle4->bindValue(1, '3'); 72$handle4->bindValue(2, '2'); 73 74$handle4->execute(); 75 76$i = 1; 77print("Handle 4:\n"); 78do { 79 print('Rowset ' . $i++ . "\n"); 80 if ($handle1->columnCount() > 0) 81 print("Results detected\n"); 82} while($handle1->nextRowset()); 83 84$db->query("DROP TABLE test"); 85?> 86--CLEAN-- 87<?php 88require __DIR__ . '/mysql_pdo_test.inc'; 89MySQLPDOTest::dropTestTable(); 90?> 91--EXPECT-- 92Handle 1: 93Rowset 1 94Rowset 2 95Results detected 96Rowset 3 97Handle 2: 98Rowset 1 99Results detected 100Rowset 2 101Handle 3: 102Rowset 1 103Rowset 2 104Results detected 105Handle 4: 106Rowset 1 107Rowset 2 108Rowset 3 109Results detected 110