1--TEST--
2mysqli_field_tell()
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifconnectfailure.inc');
7?>
8--FILE--
9<?php
10    require_once("connect.inc");
11
12    require('table.inc');
13    if (!$res = mysqli_query($link, "SELECT id FROM test ORDER BY id LIMIT 1", MYSQLI_USE_RESULT)) {
14        printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
15    }
16
17    var_dump(mysqli_field_tell($res));
18    var_dump(mysqli_field_tell($res));
19    var_dump(mysqli_fetch_field($res));
20    var_dump(mysqli_fetch_field($res));
21    var_dump(mysqli_field_tell($res));
22
23    try {
24        var_dump(mysqli_field_seek($res, 2));
25    } catch (\ValueError $e) {
26        echo $e->getMessage() . \PHP_EOL;
27    }
28    var_dump(mysqli_field_tell($res));
29
30    try {
31        var_dump(mysqli_field_seek($res, -1));
32    } catch (\ValueError $e) {
33        echo $e->getMessage() . \PHP_EOL;
34    }
35    var_dump(mysqli_field_tell($res));
36
37    var_dump(mysqli_field_seek($res, 0));
38    var_dump(mysqli_field_tell($res));
39
40
41
42    mysqli_free_result($res);
43
44    try {
45        mysqli_field_tell($res);
46    } catch (Error $exception) {
47        echo $exception->getMessage() . "\n";
48    }
49
50    mysqli_close($link);
51
52    print "done!";
53?>
54--CLEAN--
55<?php
56    require_once("clean_table.inc");
57?>
58--EXPECTF--
59int(0)
60int(0)
61object(stdClass)#%d (13) {
62  ["name"]=>
63  string(2) "id"
64  ["orgname"]=>
65  string(2) "id"
66  ["table"]=>
67  string(4) "test"
68  ["orgtable"]=>
69  string(4) "test"
70  ["def"]=>
71  string(0) ""
72  ["db"]=>
73  string(%d) "%s"
74  ["catalog"]=>
75  string(%d) "%s"
76  ["max_length"]=>
77  int(0)
78  ["length"]=>
79  int(11)
80  ["charsetnr"]=>
81  int(63)
82  ["flags"]=>
83  int(49155)
84  ["type"]=>
85  int(3)
86  ["decimals"]=>
87  int(0)
88}
89bool(false)
90int(1)
91mysqli_field_seek(): Argument #2 ($index) must be less than the number of fields for this result set
92int(1)
93mysqli_field_seek(): Argument #2 ($index) must be greater than or equal to 0
94int(1)
95bool(true)
96int(0)
97mysqli_result object is already closed
98done!
99