1--TEST--
2mysqli_more_results()
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8?>
9--FILE--
10<?php
11    require 'table.inc';
12
13    print "[004]\n";
14    var_dump(mysqli_more_results($link));
15
16    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"))
17        printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
18    print "[006]\n";
19    $i = 1;
20
21    if (mysqli_get_server_version($link) > 41000 && !($ret = mysqli_more_results($link)))
22        printf("[007] Expecting boolean/true, got %s/%s\n", gettype($ret), $ret);
23    do {
24        $res = mysqli_store_result($link);
25        mysqli_free_result($res);
26        if (mysqli_more_results($link))
27            printf("%d\n", $i++);
28    } while (mysqli_next_result($link));
29
30    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"))
31        printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
32    print "[010]\n";
33    $i = 1;
34    if (mysqli_get_server_version($link) > 41000 && !($ret = mysqli_more_results($link)))
35        printf("[011] Expecting boolean/true, got %s/%s\n", gettype($ret), $ret);
36
37    do {
38        $res = mysqli_use_result($link);
39        // NOTE: if you use mysqli_use_result() with mysqli_more_results() or any other info function,
40        // you must fetch all rows before you can loop to the next result set!
41        // See also the MySQL Reference Manual: mysql_use_result()
42        while ($row = mysqli_fetch_array($res))
43            ;
44        mysqli_free_result($res);
45        if (mysqli_more_results($link))
46            printf("%d\n", $i++);
47    } while (mysqli_next_result($link));
48
49    mysqli_close($link);
50
51    try {
52        mysqli_more_results($link);
53    } catch (Error $exception) {
54        echo $exception->getMessage() . "\n";
55    }
56
57    print "done!";
58?>
59--CLEAN--
60<?php
61    require_once 'clean_table.inc';
62?>
63--EXPECT--
64[004]
65bool(false)
66[006]
671
682
69[010]
701
712
72mysqli object is already closed
73done!
74