1--TEST--
2mysqli_field_count()
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_field_count()))
17		printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
18
19	if (!is_null($tmp = @mysqli_field_count($link)))
20		printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
21
22	require('table.inc');
23
24	var_dump(mysqli_field_count($link));
25
26	if (!$res = mysqli_query($link, "SELECT * FROM test ORDER BY id LIMIT 1")) {
27		printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
28	}
29
30	var_dump(mysqli_field_count($link));
31
32	mysqli_free_result($res);
33
34	if (!mysqli_query($link, "INSERT INTO test(id, label) VALUES (100, 'x')"))
35		printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
36	var_dump($link->field_count);
37	var_dump(mysqli_field_count($link));
38
39	if (!$res = mysqli_query($link, "SELECT NULL as _null, '' AS '', 'three' AS 'drei'"))
40		printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
41	var_dump(mysqli_field_count($link));
42	mysqli_free_result($res);
43
44	mysqli_close($link);
45
46	var_dump(mysqli_field_count($link));
47
48	print "done!";
49?>
50--CLEAN--
51<?php
52	require_once("clean_table.inc");
53?>
54--EXPECTF--
55int(0)
56int(2)
57int(0)
58int(0)
59int(3)
60
61Warning: mysqli_field_count(): Couldn't fetch mysqli in %s on line %d
62bool(false)
63done!
64