|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-09-05 15:29 UTC] andrey@php.net
[2011-09-05 15:35 UTC] andrey@php.net
-Status: Open
+Status: Assigned
-Assigned To:
+Assigned To: andrey
[2011-09-05 15:35 UTC] andrey@php.net
-Status: Assigned
+Status: Closed
[2011-09-05 15:35 UTC] andrey@php.net
[2011-09-05 15:37 UTC] andrey@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 09:00:01 2025 UTC |
Description: ------------ As the description says, there is wrong check in mysqli, which doesn't allow the mysqlnd code to run. mysqli returns always 0 for num_rows() even if the whole result set has been read. This bug exists since 5.3.0, which first bundled mysqli with mysqlnd. Test script: --------------- ./php -r '$c=mysqli_connect("127.0.0.1","root","root","test");var_dump($c->real_query("SELECT 1"));var_dump($res=$c->use_result(), mysqli_num_rows($res), $res->fetch_assoc(), mysqli_num_rows($res), $res->fetch_assoc(), mysqli_num_rows($res));' Expected result: ---------------- Warning: mysqli_num_rows(): Function cannot be used with MYSQL_USE_RESULT in Command line code on line 1 Warning: mysqli_num_rows(): Function cannot be used with MYSQL_USE_RESULT in Command line code on line 1 object(mysqli_result)#2 (5) { ["current_field"]=> int(0) ["field_count"]=> int(1) ["lengths"]=> array(1) { [0]=> int(1) } ["num_rows"]=> int(1) ["type"]=> int(0) } int(0) array(1) { [1]=> string(1) "1" } int(0) NULL int(1) ----- here is the difference Actual result: -------------- Warning: mysqli_num_rows(): Function cannot be used with MYSQL_USE_RESULT in Command line code on line 1 Warning: mysqli_num_rows(): Function cannot be used with MYSQL_USE_RESULT in Command line code on line 1 object(mysqli_result)#2 (5) { ["current_field"]=> int(0) ["field_count"]=> int(1) ["lengths"]=> array(1) { [0]=> int(1) } ["num_rows"]=> int(1) ["type"]=> int(0) } int(0) array(1) { [1]=> string(1) "1" } int(0) NULL int(0) --- should have been 1