xref: /PHP-5.4/ext/mysqli/tests/040.phpt (revision eb0e09f5)
1--TEST--
2function test: mysqli_num_rows()
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	mysqli_query($link, "CREATE TABLE test_result (a int, b varchar(10)) ENGINE=" . $engine);
19	mysqli_query($link, "INSERT INTO test_result VALUES (1, 'foo')");
20
21	mysqli_real_query($link, "SELECT * FROM test_result");
22	if (mysqli_field_count($link)) {
23		$result = mysqli_store_result($link);
24		$num = mysqli_num_rows($result);
25		mysqli_free_result($result);
26	}
27
28	var_dump($num);
29
30	mysqli_query($link, "DROP TABLE IF EXISTS test_result");
31	mysqli_close($link);
32	print "done!";
33?>
34--CLEAN--
35<?php
36require_once("connect.inc");
37if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
38   printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
39
40if (!mysqli_query($link, "DROP TABLE IF EXISTS test_result"))
41	printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
42
43mysqli_close($link);
44?>
45--EXPECT--
46int(1)
47done!