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