1--TEST--
2mysqli_field_count()
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifconnectfailure.inc');
7?>
8--FILE--
9<?php
10    require_once("connect.inc");
11
12    require('table.inc');
13
14    var_dump(mysqli_field_count($link));
15
16    if (!$res = mysqli_query($link, "SELECT * FROM test ORDER BY id LIMIT 1")) {
17        printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
18    }
19
20    var_dump(mysqli_field_count($link));
21
22    mysqli_free_result($res);
23
24    if (!mysqli_query($link, "INSERT INTO test(id, label) VALUES (100, 'x')"))
25        printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
26    var_dump($link->field_count);
27    var_dump(mysqli_field_count($link));
28
29    if (!$res = mysqli_query($link, "SELECT NULL as _null, '' AS '', 'three' AS 'drei'"))
30        printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
31    var_dump(mysqli_field_count($link));
32    mysqli_free_result($res);
33
34    mysqli_close($link);
35
36    try {
37        mysqli_field_count($link);
38    } catch (Error $exception) {
39        echo $exception->getMessage() . "\n";
40    }
41
42    print "done!";
43--CLEAN--
44<?php
45    require_once("clean_table.inc");
46?>
47--EXPECT--
48int(0)
49int(2)
50int(0)
51int(0)
52int(3)
53mysqli object is already closed
54done!
55