1--TEST--
2PS using cursor and returning multiple result sets
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8?>
9--FILE--
10<?php
11require_once __DIR__ . '/connect.inc';
12
13mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
14$db = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
15$db->query('DROP PROCEDURE IF EXISTS testPs');
16$db->query(<<<'SQL'
17CREATE PROCEDURE testPs() BEGIN
18    DECLARE testCursor CURSOR FOR SELECT 'stuff';
19    OPEN testCursor;
20    CLOSE testCursor;
21    SELECT 1 as a, 2 as b;
22    SELECT 3 as a, 4 as b;
23END
24SQL
25);
26
27echo "use_result:\n";
28$stmt = $db->prepare("call testPs()");
29$stmt->execute();
30$stmt->bind_result($v1, $v2);
31while ($stmt->fetch()) {
32    var_dump($v1, $v2);
33}
34
35$stmt->next_result();
36$stmt->bind_result($v1, $v2);
37while ($stmt->fetch()) {
38    var_dump($v1, $v2);
39}
40$stmt->next_result();
41
42echo "\nstore_result:\n";
43$stmt = $db->prepare("call testPs()");
44$stmt->execute();
45$stmt->store_result();
46$stmt->bind_result($v1, $v2);
47while ($stmt->fetch()) {
48    var_dump($v1, $v2);
49}
50
51$stmt->next_result();
52$stmt->store_result();
53$stmt->bind_result($v1, $v2);
54while ($stmt->fetch()) {
55    var_dump($v1, $v2);
56}
57$stmt->next_result();
58
59echo "\nget_result:\n";
60$stmt = $db->prepare("call testPs()");
61$stmt->execute();
62$result = $stmt->get_result();
63while ($row = $result->fetch_assoc()) {
64    var_dump($row);
65}
66
67$stmt->next_result();
68$result = $stmt->get_result();
69while ($row = $result->fetch_assoc()) {
70    var_dump($row);
71}
72$stmt->next_result();
73
74?>
75--CLEAN--
76<?php
77require_once 'connect.inc';
78$link = new mysqli($host, $user, $passwd, $db, $port, $socket);
79$link->query('DROP PROCEDURE IF EXISTS testPs');
80$link->close();
81?>
82--EXPECT--
83use_result:
84int(1)
85int(2)
86int(3)
87int(4)
88
89store_result:
90int(1)
91int(2)
92int(3)
93int(4)
94
95get_result:
96array(2) {
97  ["a"]=>
98  int(1)
99  ["b"]=>
100  int(2)
101}
102array(2) {
103  ["a"]=>
104  int(3)
105  ["b"]=>
106  int(4)
107}
108