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