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