xref: /PHP-8.2/ext/mysqli/tests/040.phpt (revision b5a14e6c)
1--TEST--
2function test: mysqli_num_rows()
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once('skipifconnectfailure.inc');
8?>
9--FILE--
10<?php
11    require_once("connect.inc");
12
13    /*** test mysqli_connect 127.0.0.1 ***/
14    $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
15
16    mysqli_select_db($link, $db);
17
18    mysqli_query($link, "DROP TABLE IF EXISTS test_result");
19    mysqli_query($link, "CREATE TABLE test_result (a int, b varchar(10)) ENGINE=" . $engine);
20    mysqli_query($link, "INSERT INTO test_result VALUES (1, 'foo')");
21
22    mysqli_real_query($link, "SELECT * FROM test_result");
23    if (mysqli_field_count($link)) {
24        $result = mysqli_store_result($link);
25        $num = mysqli_num_rows($result);
26        mysqli_free_result($result);
27    }
28
29    var_dump($num);
30
31    mysqli_query($link, "DROP TABLE IF EXISTS test_result");
32    mysqli_close($link);
33    print "done!";
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(1)
48done!
49