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