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