1--TEST--
2mysqli_use_result()
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once('skipifconnectfailure.inc');
8?>
9--FILE--
10<?php
11    require_once("connect.inc");
12
13    require('table.inc');
14
15    if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id"))
16        printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
17
18    if (!is_object($res = mysqli_use_result($link)))
19        printf("[004] Expecting object, got %s/%s. [%d] %s\n",
20            gettype($res), $res, mysqli_errno($link), mysqli_error($link));
21
22    try {
23        var_dump(mysqli_data_seek($res, 2));
24    } catch (\Error $e) {
25        echo $e->getMessage() . \PHP_EOL;
26    }
27
28    mysqli_free_result($res);
29
30    if (!mysqli_query($link, "DELETE FROM test"))
31        printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
32
33    if (false !== ($res = mysqli_use_result($link)))
34        printf("[007] Expecting boolean/false, got %s/%s. [%d] %s\n",
35            gettype($res), $res, mysqli_errno($link), mysqli_error($link));
36
37    if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id"))
38        printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
39
40    if (false !== ($tmp = mysqli_data_seek($res, 1)))
41        printf("[009] Expecting boolean/false, got %s/%s\n",
42            gettype($tmp), $tmp);
43
44    mysqli_close($link);
45
46    try {
47        mysqli_use_result($link);
48    } catch (Error $exception) {
49        echo $exception->getMessage() . "\n";
50    }
51
52    print "done!";
53?>
54--CLEAN--
55<?php
56    require_once("clean_table.inc");
57?>
58--EXPECT--
59mysqli_data_seek() cannot be used in MYSQLI_USE_RESULT mode
60mysqli object is already closed
61done!
62