Bug #55582 [Asn->Csd]: mysqli_num_rows() returns always 0 for unbuffered, when mysqlnd is used
| From: | andrey@php.net | Date: | Mon, 05 Sep 2011 15:35:48 +0000 |
| Subject: | Bug #55582 [Asn->Csd]: mysqli_num_rows() returns always 0 for unbuffered, when mysqlnd is used | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-163301@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=55582&edit=1
ID: 55582
Updated by: andrey@php.net
Reported by: andrey@php.net
Summary: mysqli_num_rows() returns always 0 for unbuffered,
when mysqlnd is used
-Status: Assigned
+Status: Closed
Type: Bug
Package: MySQLi related
Operating System: all
PHP Version: 5.4SVN-2011-09-05 (SVN)
Assigned To: andrey
Block user comment: N
Private report: N
New Comment:
This bug has been fixed in SVN.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
For Windows:
http://windows.php.net/snapshots/
Thank you for the report, and for helping us make PHP better.
Fixed in SVN, to appear in 5.3.9
Previous Comments:
------------------------------------------------------------------------
[2011-09-05 15:29:32] andrey@php.net
Automatic comment from SVN on behalf of andrey
Revision: http://svn.php.net/viewvc/?view=revision&revision=316188
Log: Fix for Bug #55582 mysqli_num_rows() returns always 0 for unbuffered, when mysqlnd is used
------------------------------------------------------------------------
[2011-09-05 09:49:29] andrey@php.net
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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=55582&edit=1