php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #45080 PDOStatement - Mysql Driver - rowCount
Submitted: 2008-05-23 13:10 UTC Modified: 2008-08-20 22:46 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: paul dot cocei at gmail dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.2.6 OS: CentOS 5.1
Private report: No CVE-ID: None
 [2008-05-23 13:10 UTC] paul dot cocei at gmail dot com
Description:
------------
Because libmysql contains a method named mysql_stmt_num_rows, it is possible in the mysql PDO driver to return correctly the total count of rows selected by a SELECT statement.
Right now, the source code for mysql PDOStatement uses mysql_stmt_affected_rows, which evidentely returns "0" for SELECT queries.

Localization: php-5.2.6/ext/pdo_mysql.c, line 202.

Reproduce code:
---------------
row_count = mysql_stmt_affected_rows(S->stmt);


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-08-20 22:46 UTC] kalle@php.net
This is expected behavior, the manual also says that the rowCount will return affected rows.
 [2013-08-22 01:17 UTC] jmichae3 at yahoo dot com
I am having this problem too, and so are other people on the net. getting 0 always from rowCount() on SELECT.
 [2013-08-22 01:20 UTC] jmichae3 at yahoo dot com
since it's not defined in the manual, to me, "affected rows" simply means the rows in question. are you speaking of UPDATE and DELETE? please put in better documentation on this function that explains the definition of "affected rows", thanks.

if rowCount doesn't always return the row count, what are we supposed to use to get the row count?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 29 16:01:32 2024 UTC