xref: /PHP-8.1/ext/mysqli/tests/bug55582.phpt (revision b5a14e6c)
1--TEST--
2Bug #55582 mysqli_num_rows() returns always 0 for unbuffered, when mysqlnd is used
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once('skipifconnectfailure.inc');
8require_once("connect.inc");
9?>
10--FILE--
11<?php
12    include "connect.inc";
13    if (!($link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))) {
14        printf("[001] Cannot connect to the server");
15    }
16
17    var_dump($link->real_query("SELECT 1"));
18    $res = $link->use_result();
19    try {
20        var_dump(mysqli_num_rows($res));
21    } catch (\Error $e) {
22        echo $e->getMessage() . \PHP_EOL;
23    }
24    var_dump($res->fetch_assoc());
25    try {
26        var_dump(mysqli_num_rows($res));
27    } catch (\Error $e) {
28        echo $e->getMessage() . \PHP_EOL;
29    }
30    var_dump($res->fetch_assoc());
31    var_dump(mysqli_num_rows($res));
32
33    $link->close();
34    echo "done\n";
35?>
36--EXPECT--
37bool(true)
38mysqli_num_rows() cannot be used in MYSQLI_USE_RESULT mode
39array(1) {
40  [1]=>
41  string(1) "1"
42}
43mysqli_num_rows() cannot be used in MYSQLI_USE_RESULT mode
44NULL
45int(1)
46done
47