1--TEST--
2function test: mysqli_num_fields()
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
8mysqli_check_skip_test();
9?>
10--FILE--
11<?php
12require_once dirname(__DIR__) . "/test_setup/test_helpers.inc";
13
14    $link = default_mysqli_connect();
15
16    mysqli_query($link, "CREATE TABLE test_mysqli_num_fields (a int, b varchar(10)) ENGINE = " . get_default_db_engine());
17
18    mysqli_query($link, "INSERT INTO test_mysqli_num_fields VALUES (1, 'foo')");
19
20    mysqli_real_query($link, "SELECT * FROM test_mysqli_num_fields");
21    if (mysqli_field_count($link)) {
22        $result = mysqli_store_result($link);
23        $num = mysqli_num_fields($result);
24        mysqli_free_result($result);
25    }
26
27    var_dump($num);
28
29    mysqli_close($link);
30?>
31--CLEAN--
32<?php
33require_once(dirname(__DIR__) . "/test_setup/test_helpers.inc");
34tear_down_table_on_default_connection('test_mysqli_num_fields');
35?>
36--EXPECT--
37int(2)
38