php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #54704 mysql_num_rows() does work with mysql_unbuffered_query()
Submitted: 2011-05-11 00:38 UTC Modified: 2011-12-05 21:55 UTC
From: juangiordana at gmail dot com Assigned: frozenfire (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.3.6 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: juangiordana at gmail dot com
New email:
PHP Version: OS:

 

 [2011-05-11 00:38 UTC] juangiordana at gmail dot com
Description:
------------
mysql_num_rows() does work with mysql_unbuffered_query() if all the rows in the result have been retrieved.

---
From manual page: http://www.php.net/function.mysql-unbuffered-query#Notes
---

"you cannot use mysql_num_rows() and mysql_data_seek() on a result set returned from mysql_unbuffered_query()"

---
From manual page: http://www.php.net/function.mysql-num-rows#Notes
---

"If you use mysql_unbuffered_query(), mysql_num_rows() will not return the correct value until all the rows in the result set have been retrieved."

Test script:
---------------
<?php
$sql = 'SELECT `id` FROM `table`';
$result = mysql_query($sql);
echo mysql_num_rows($result) . " results from buffered query.\n";
mysql_free_result($result);

$sql = 'SELECT `id` FROM `table`';
$result = mysql_unbuffered_query($sql);
echo mysql_num_rows($result) . " results from unfinished unbuffered query.\n";
while ($row = mysql_fetch_assoc($result)) {
    //
}
echo mysql_num_rows($result) . " results from finished unbuffered query.\n";
?>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-09-02 13:34 UTC] uw@php.net
-Status: Open +Status: Feedback
 [2011-09-02 13:34 UTC] uw@php.net
I am not sure what you are saying here. Are you saying it is a bug in ext/mysql ? It is filed as a documentation problem but the documentation is correct here.

I cannot reproduce any issues with mysql_num_rows() and mysql_unbuffered_query(). Please, provide a full example including table structure, table data loading and information on how you compiled PHP (with mysqlnd or libmysql support, if libmysql, which version).
 [2011-09-02 13:35 UTC] uw@php.net
Automatic comment from SVN on behalf of uw
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=316038
Log: Coverage for bug#54704, of which I think it is bogus, thus no dedicated test.
 [2011-09-02 22:11 UTC] juangiordana at gmail dot com
-Status: Feedback +Status: Open
 [2011-09-02 22:11 UTC] juangiordana at gmail dot com
Hello,

The report is about a documenation problem.

The documentation for mysql_unbuffered_query() says that "you **cannot** use mysql_num_rows()", but you ***can*** use it, as stated in the manual page of mysql_num_rows(), once you retrived all the rows from the result set.
 [2011-12-05 21:55 UTC] frozenfire@php.net
Automatic comment from SVN on behalf of frozenfire
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=320465
Log: Clarified that certain commands can be used on a result set from mysql_unbuffered_query after all rows have been fetched. Closes bug #54704.
 [2011-12-05 21:55 UTC] frozenfire@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 [2011-12-05 21:55 UTC] frozenfire@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: frozenfire
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 30 10:01:29 2024 UTC