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