xref: /PHP-7.0/ext/mysqli/tests/038.phpt (revision eb0e09f5)
1--TEST--
2function test: mysqli_num_fields()
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifconnectfailure.inc');
7?>
8--FILE--
9<?php
10	require_once("connect.inc");
11
12	/*** test mysqli_connect 127.0.0.1 ***/
13	$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
14
15	mysqli_select_db($link, $db);
16
17	mysqli_query($link, "DROP TABLE IF EXISTS test_result");
18
19	mysqli_query($link, "CREATE TABLE test_result (a int, b varchar(10)) ENGINE = " . $engine);
20
21	mysqli_query($link, "INSERT INTO test_result VALUES (1, 'foo')");
22
23	mysqli_real_query($link, "SELECT * FROM test_result");
24	if (mysqli_field_count($link)) {
25		$result = mysqli_store_result($link);
26		$num = mysqli_num_fields($result);
27		mysqli_free_result($result);
28	}
29
30	var_dump($num);
31
32	mysqli_query($link, "DROP TABLE IF EXISTS test_result");
33	mysqli_close($link);
34?>
35--CLEAN--
36<?php
37require_once("connect.inc");
38if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
39   printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
40
41if (!mysqli_query($link, "DROP TABLE IF EXISTS test_result"))
42	printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
43
44mysqli_close($link);
45?>
46--EXPECT--
47int(2)
48