xref: /PHP-5.3/ext/pdo_mysql/tests/bug_61207.phpt (revision b526e0e4)
1--TEST--
2PDO MySQL Bug #61207 (PDO::nextRowset() after a multi-statement query doesn't always work)
3--SKIPIF--
4<?php
5if (!extension_loaded('pdo') || !extension_loaded('pdo_mysql')) die('skip not loaded');
6require dirname(__FILE__) . '/config.inc';
7require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
8PDOTest::skip();
9?>
10--FILE--
11<?php
12require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
13
14$link = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
15
16$link->query('create table `bug61207`( `id` int )');
17
18$handle1 = $link->prepare('insert into bug61207(id) values(1);
19                          select * from bug61207 where id = ?;
20                          update bug61207 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 = $link->prepare('select * from bug61207 where id = ?;
35                           update bug61207 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 = $link->prepare('update bug61207 set id = 2 where id = ?;
51                           select * from bug61207 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 = $link->prepare('insert into bug61207(id) values(3);
67                           update bug61207 set id = 2 where id = ?;
68                           select * from bug61207 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$link->query("DROP TABLE bug61207");
84?>
85--EXPECT--
86Handle 1:
87Rowset 1
88Rowset 2
89Results detected
90Rowset 3
91Handle 2:
92Rowset 1
93Results detected
94Rowset 2
95Handle 3:
96Rowset 1
97Rowset 2
98Results detected
99Handle 4:
100Rowset 1
101Rowset 2
102Rowset 3
103Results detected
104