note 77722 deleted from pdostatement.rowcount by joey
| From: | joey@php.net | Date: | Mon, 18 Jul 2011 23:05:45 +0000 |
| Subject: | note 77722 deleted from pdostatement.rowcount by joey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-181676@lists.php.net to get a copy of this message | ||
Note Submitter: evangun2001 at yahoo dot fr
----
hipska at mac dot com : what you say is not correct.
The resulting $fruits cannot be used as an array, and count($fruits) always equals 1.
The confusion is however understandable, since foreach ($fruits->query($query) as $row){} will
work, as with any array.
The most efficient way to retrieve number of rows found by SELECT in a portable application is
probably to make a condition :
- Check that the current database system (get its name via getAttribute()), is one where rowCount()
returns the number of rows found
1) If it does, there you have it
2) If it does not, execute an extra COUNT query.