xref: /php-src/ext/mysqli/tests/bug55582.phpt (revision a21edc52)
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';
8?>
9--FILE--
10<?php
11    include 'connect.inc';
12    if (!($link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))) {
13        printf("[001] Cannot connect to the server");
14    }
15
16    var_dump($link->real_query("SELECT 1"));
17    $res = $link->use_result();
18    try {
19        var_dump(mysqli_num_rows($res));
20    } catch (\Error $e) {
21        echo $e->getMessage() . \PHP_EOL;
22    }
23    var_dump($res->fetch_assoc());
24    try {
25        var_dump(mysqli_num_rows($res));
26    } catch (\Error $e) {
27        echo $e->getMessage() . \PHP_EOL;
28    }
29    var_dump($res->fetch_assoc());
30    var_dump(mysqli_num_rows($res));
31
32    $link->close();
33    echo "done\n";
34?>
35--EXPECT--
36bool(true)
37mysqli_num_rows() cannot be used in MYSQLI_USE_RESULT mode
38array(1) {
39  [1]=>
40  string(1) "1"
41}
42mysqli_num_rows() cannot be used in MYSQLI_USE_RESULT mode
43NULL
44int(1)
45done
46