1--TEST--
2mysqli_more_results()
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifemb.inc');
7require_once('skipifconnectfailure.inc');
8?>
9--FILE--
10<?php
11	require_once("connect.inc");
12
13	$tmp    = NULL;
14	$link   = NULL;
15
16	if (!is_null($tmp = @mysqli_more_results()))
17		printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
18
19	if (!is_null($tmp = @mysqli_more_results($link)))
20		printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
21
22	require('table.inc');
23
24	print "[004]\n";
25	var_dump(mysqli_more_results($link));
26
27	if (!mysqli_multi_query($link, "SELECT 1 AS a; SELECT 1 AS a, 2 AS b; SELECT id FROM test ORDER BY id LIMIT 3"))
28		printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
29	print "[006]\n";
30	$i = 1;
31
32	if (mysqli_get_server_version($link) > 41000 && !($ret = mysqli_more_results($link)))
33		printf("[007] Expecting boolean/true, got %s/%s\n", gettype($ret), $ret);
34	do {
35		$res = mysqli_store_result($link);
36		mysqli_free_result($res);
37		if (mysqli_more_results($link))
38			printf("%d\n", $i++);
39	} while (mysqli_next_result($link));
40
41	if (!mysqli_multi_query($link, "SELECT 1 AS a; SELECT 1 AS a, 2 AS b; SELECT id FROM test ORDER BY id LIMIT 3"))
42		printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
43	print "[010]\n";
44	$i = 1;
45	if (mysqli_get_server_version($link) > 41000 && !($ret = mysqli_more_results($link)))
46		printf("[011] Expecting boolean/true, got %s/%s\n", gettype($ret), $ret);
47
48	do {
49		$res = mysqli_use_result($link);
50		// NOTE: if you use mysqli_use_result() with mysqli_more_results() or any other info function,
51		// you must fetch all rows before you can loop to the next result set!
52		// See also the MySQL Reference Manual: mysql_use_result()
53		while ($row = mysqli_fetch_array($res))
54			;
55		mysqli_free_result($res);
56		if (mysqli_more_results($link))
57			printf("%d\n", $i++);
58	} while (mysqli_next_result($link));
59
60	mysqli_close($link);
61
62	var_dump(mysqli_more_results($link));
63
64	print "done!";
65?>
66--CLEAN--
67<?php
68	require_once("clean_table.inc");
69?>
70--EXPECTF--
71[004]
72bool(false)
73[006]
741
752
76
77Strict Standards: mysqli_next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method in %s on line %d
78[010]
791
802
81
82Strict Standards: mysqli_next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method in %s on line %d
83
84Warning: mysqli_more_results(): Couldn't fetch mysqli in %s on line %d
85bool(false)
86done!
87