1--TEST--
2mysqli_fetch_field_direct()
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifemb.inc');
7require_once('skipifconnectfailure.inc');
8?>
9--FILE--
10<?php
11	require_once("connect.inc");
12
13	$tmp    = NULL;
14	$link   = NULL;
15
16	if (!is_null($tmp = @mysqli_fetch_field_direct()))
17		printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
18
19	if (!is_null($tmp = @mysqli_fetch_field_direct($link)))
20		printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
21
22	if (!is_null($tmp = @mysqli_fetch_field_direct($link, $link)))
23		printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
24
25	require('table.inc');
26
27	if (!$res = mysqli_query($link, "SELECT id AS ID, label FROM test AS TEST ORDER BY id LIMIT 1")) {
28		printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
29	}
30
31	var_dump(mysqli_fetch_field_direct($res, -1));
32	var_dump(mysqli_fetch_field_direct($res, 0));
33	var_dump(mysqli_fetch_field_direct($res, 2));
34
35	mysqli_free_result($res);
36
37	if (NULL !== ($tmp = mysqli_fetch_field_direct($res, 0)))
38		printf("Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
39
40	mysqli_close($link);
41	print "done!";
42?>
43--CLEAN--
44<?php
45	require_once("clean_table.inc");
46?>
47--EXPECTF--
48Warning: mysqli_fetch_field_direct(): Field offset is invalid for resultset in %s on line %d
49bool(false)
50object(stdClass)#%d (13) {
51  ["name"]=>
52  string(2) "ID"
53  ["orgname"]=>
54  string(2) "id"
55  ["table"]=>
56  string(4) "TEST"
57  ["orgtable"]=>
58  string(4) "test"
59  ["def"]=>
60  string(0) ""
61  ["db"]=>
62  string(%d) "%s"
63  ["catalog"]=>
64  string(%d) "%s"
65  ["max_length"]=>
66  int(%d)
67  ["length"]=>
68  int(%d)
69  ["charsetnr"]=>
70  int(%d)
71  ["flags"]=>
72  int(%d)
73  ["type"]=>
74  int(%d)
75  ["decimals"]=>
76  int(%d)
77}
78
79Warning: mysqli_fetch_field_direct(): Field offset is invalid for resultset in %s on line %d
80bool(false)
81
82Warning: mysqli_fetch_field_direct(): Couldn't fetch mysqli_result in %s on line %d
83done!
84