Bug #80142 [Opn]: PDO provides no way to get number of rows in result

From: Date: Wed, 23 Sep 2020 17:43:03 +0000
Subject: Bug #80142 [Opn]: PDO provides no way to get number of rows in result
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-229186@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80142&edit=1 ID: 80142 Updated by: daverandom@php.net Reported by: teo8976 at gmail dot com Summary: PDO provides no way to get number of rows in result Status: Open Type: Bug Package: PDO MySQL Operating System: all PHP Version: Irrelevant Block user comment: N Private report: N New Comment: https://www.php.net/manual/en/pdostatement.rowcount.php Previous Comments: ------------------------------------------------------------------------ [2020-09-23 17:40:57] teo8976 at gmail dot com Description: ------------ 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. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80142&edit=1

« previous php.bugs (#229186) next »