|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80142 PDO provides no way to get number of rows in result
Submitted: 2020-09-23 17:40 UTC Modified: 2020-09-23 17:43 UTC
From: teo8976 at gmail dot com Assigned:
Status: Not a bug Package: PDO MySQL
PHP Version: Irrelevant OS: all
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: teo8976 at gmail dot com
New email:
PHP Version: OS:


 [2020-09-23 17:40 UTC] teo8976 at gmail dot com
MySQLi has $result->num_rows that tells you the number of rows in a result. There are countless use cases for wanting to know the number of results before fetching them (I'm not even saying "without" fetching them because then you could do a COUNT() query to begin with).

There's no way to do that in PDO.

If you have already executed a query and want to know the number of rows in the result, you need to fetch them all, or to do an extra COUNT query.

That is ridiculous.

This is a very well known crippling limitation in PDO, how comes it hasn't been fixed yet?? Forums are full of questions like "how to get the row count in PDO", and obviously the answers are all pathetically insufficient workarounds.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-09-23 17:43 UTC]
-Status: Open +Status: Not a bug
 [2020-09-23 17:43 UTC]
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 07:01:29 2024 UTC