note 59100 deleted from function.pdostatement-rowcount by dbs
| From: | dbs@php.net | Date: | Thu, 15 Dec 2005 20:27:32 +0000 |
| Subject: | note 59100 deleted from function.pdostatement-rowcount by dbs | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-100227@lists.php.net to get a copy of this message | ||
Note Submitter: justin dot rebelo at etrafficsolutions dot com
----
I find it spellbinding that there is no recordCount() or similar method for counting the number of
SELECT results in a PDOStatement object. The only possible explanation I can fathom for this is that
the query code is avoiding doing any implicit counting to reduce overhead and leaving it up to the
user to explicity count them. Fair enough, so why not make a numRows or similar method which does
just that?
I would love to heard a good reason why this is as it is, but I really cannot think of any good
reason.
And the previous post about a second COUNT(*) query to deal with it is bang on. That's a
terrible workaround, not just from an integrity point of view, but also the overhead of more
database access is going to be greater (certainly with complex queries with lots of joining) than
simply counting the number of rows in the object's results member property.