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