[RCD] PDO-based DB layer

Geert Wirken geert at gwirken.nl
Mon Jul 23 11:27:13 CEST 2012

On 23-07-12 09:23, A.L.E.C wrote:
> affected_rows() is not the same. It shouldn't be used for SELECT
> statements. I removed num_rows() because it was used only in one place
> and because it can be simply replaced by looping on fetch_array() if
> needed. rcube_contacts doesn't use num_rows() any more.

It occurs to me that looping on a (large) data set is quite inefficient, 
one could better use a SELECT COUNT() to find the number of rows.

@Phil: PDO does not offer a function like num_rows, it only offers 
rowCount() (http://php.net/manual/en/pdostatement.rowcount.php) which 
returns the number of affected rows. In MySQL, the effect is the same 
(rowCount returns the number of rows in a select) but this behavior does 
not necessarily extend to other databases. It would be safer to rely on 
other methods to find the number of rows.


More information about the dev mailing list