summaryrefslogtreecommitdiff
path: root/ext/mysqli/tests/mysqli_stmt_multires.phpt
blob: 47b56b3dd91870ab86f8205cb71f832de7448da9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
--TEST--
Multiple result set with PS
--SKIPIF--
<?php
require_once('skipif.inc');
require_once("connect.inc");
if (!$IS_MYSQLND) {
    die("skip mysqlnd only test");
}
require_once('skipifconnectfailure.inc');
?>
--FILE--
<?php
	require_once("connect.inc");
	require('table.inc');

	$stmt = mysqli_stmt_init($link);
	if (!$link->query('DROP PROCEDURE IF EXISTS p123')) {
		printf("[001] [%d] %s\n", $link->error, $link->errno);
	}

	if (!$link->query("CREATE PROCEDURE p123() BEGIN SELECT id+12, CONCAT_WS('-',label,'ahoi') FROM test ORDER BY id LIMIT 1; SELECT id + 42, CONCAT_WS('---',label, label) FROM test ORDER BY id LIMIT 1; END")) {
		printf("[002] [%d] %s\n", $link->error, $link->errno);
	}

	if (!($stmt = $link->prepare("CALL p123"))) {
		printf("[003] [%d] %s\n", $stmt->error, $stmt->errno);
	}

	if (!$stmt->execute()) {
		printf("[005] [%d] %s\n", $stmt->error, $stmt->errno);
	}

	$c_id = NULL;
	$c_label = NULL;
	if (!$stmt->bind_result($c_id, $c_label)) {
		printf("[004] [%d] %s\n", $stmt->error, $stmt->errno);
	}
	var_dump("pre:",$c_id, $c_label);

	if (!$stmt->fetch()) {
		printf("[006] [%d] %s\n", $stmt->error, $stmt->errno);
	}

	var_dump("post:",$c_id, $c_label);

	if ($stmt->fetch()) {
		printf("[007] Shouldn't have fetched anything\n");
		var_dump($c_id, $c_label);
	}

	if ($stmt->fetch()) {
		printf("[008] No more rows expected\n");
	}

	if (!$stmt->more_results()) {
		printf("[009] Expected more results\n");
	} else {
		var_dump("[009] next_result:", $stmt->next_result());
	}

	if (!$stmt->bind_result($c_id, $c_label)) {
		printf("[010] [%d] %s\n", $stmt->error, $stmt->errno);
	}
	var_dump("pre:",$c_id, $c_label);

	if (!$stmt->fetch()) {
		printf("[011] [%d] %s\n", $stmt->error, $stmt->errno);
	}

	var_dump("post:",$c_id, $c_label);

	if ($stmt->fetch()) {
		printf("[012] No more rows expected\n");
	}

	if (!$stmt->more_results()) {
		printf("[013] Expected more results\n");
	} else {
		var_dump("[013] next_result:", $stmt->next_result());
	}

	if ($stmt->more_results()) {
		printf("[014] No more results expected\n");
	} else {
		printf("[014] No result, as expected\n");
	}

	$stmt->close();
	$link->close();


	echo "done";
?>
--CLEAN--
<?php
	require_once("connect.inc");
	if (!$link->query('DROP PROCEDURE IF EXISTS p123')) {
		printf("[001] [%d] %s\n", $link->error, $link->errno);
	}
?>
--EXPECTF--
string(4) "pre:"
NULL
NULL
string(5) "post:"
int(13)
string(6) "a-ahoi"
string(18) "[009] next_result:"
bool(true)
string(4) "pre:"
int(13)
string(6) "a-ahoi"
string(5) "post:"
int(43)
string(5) "a---a"
string(18) "[013] next_result:"
bool(true)
[014] No result, as expected
done