5
require_once('skipif.inc');
6
require_once('skipifemb.inc');
7
require_once('skipifconnectfailure.inc');
11
include "connect.inc";
14
if (defined('E_STRICT')) {
15
error_reporting(((int)ini_get('error_reporting')) | E_STRICT );
22
if (!is_null($tmp = @mysqli_next_result()))
23
printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
25
if (!is_null($tmp = @mysqli_next_result($link)))
26
printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
33
if (false !== ($tmp = mysqli_next_result($link)))
34
printf("[003] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
37
$tmp = ob_get_contents();
39
if (!preg_match('@Strict Standards: mysqli_next_result\(\): There is no next result set@ismU', $tmp)) {
40
printf("[003a] Strict Standards warning missing\n");
42
$tmp = trim(preg_replace('@Strict Standards: mysqli_next_result\(\).*on line \d+@ism', '', $tmp));
44
print trim($tmp) . "\n";
48
$res = mysqli_query($link, "SELECT 1 AS res");
49
if (false !== ($tmp = mysqli_next_result($link)))
50
printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
53
$tmp = ob_get_contents();
55
if (!preg_match('@Strict Standards: mysqli_next_result\(\): There is no next result set@ismU', $tmp)) {
56
printf("[004a] Strict Standards warning missing\n");
58
$tmp = trim(preg_replace('@Strict Standards: mysqli_next_result\(\).*on line \d+@ism', '', $tmp));
60
print trim($tmp) . "\n";
63
mysqli_free_result($res);
65
function func_test_mysqli_next_result($link, $query, $offset, $num_results, $strict_on) {
67
if (!mysqli_multi_query($link, $query))
68
printf("[%03d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
75
if ($res = mysqli_store_result($link)) {
76
mysqli_free_result($res);
79
} while (true === mysqli_next_result($link));
82
$tmp = ob_get_contents();
84
if (!preg_match('@Strict Standards: mysqli_next_result\(\): There is no next result set@ismU', $tmp)) {
85
printf("[%03d] Strict Standards warning missing\n", $offset + 1);
87
$tmp = trim(preg_replace('@Strict Standards: mysqli_next_result\(\).*on line \d+@ism', '', $tmp));
89
print trim($tmp) . "\n";
92
if ($i !== $num_results) {
93
printf("[%03d] Expecting %d result(s), got %d result(s)\n", $offset + 2, $num_results, $i);
96
if (mysqli_more_results($link))
97
printf("[%03d] mysqli_more_results() indicates more results than expected\n", $offset + 3);
99
if (!($res = mysqli_query($link, "SELECT 1 AS b"))) {
100
printf("[%03d] [%d] %s\n", $offset + 4, mysqli_errno($link), mysqli_error($link));
102
mysqli_free_result($res);
107
func_test_mysqli_next_result($link, "SELECT 1 AS a; SELECT 1 AS a, 2 AS b; SELECT id FROM test ORDER BY id LIMIT 3", 5, 3, $strict_on);
108
func_test_mysqli_next_result($link, "SELECT 1 AS a; INSERT INTO test(id, label) VALUES (100, 'y'); SELECT 1 AS a, 2 AS b", 8, 2, $strict_on);
109
func_test_mysqli_next_result($link, "DELETE FROM test WHERE id >= 100; SELECT 1 AS a; ", 11, 1, $strict_on);
113
var_dump(mysqli_next_result($link));
118
Warning: mysqli_next_result(): Couldn't fetch mysqli in %s on line %d
b'\\ No newline at end of file'