DB_num_rows
The equivalent of mysqli_num_rows doesn't exist for PDO (or at least, it sort of does, with some drivers, but it's not guaranteed, that's another story).
So, using DB_num_rows() will be inefficient for any driver that doesn't support counting the number of rows.
(I encountered this while working on the Doctrine DBAL layer).
90% of the time, DB_num_rows() is being used to check if there are rows, when the result of DB_fetch_row() / DB_fetch_assoc() / DB_fetch_array() will be === false if there are no rows.
In the code I'm writing I 'cheat' by checking if the result set has columns, which PDO supports, and only count if there are columns, which should avoid a performance hit for most of the times DB_num_rows() is used.
|