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