Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DB_num_rows
03-28-2014, 05:22 PM
Post: #1
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.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
DB_num_rows - serakfalcon - 03-28-2014 05:22 PM
RE: DB_num_rows - phil - 03-29-2014, 02:40 PM
RE: DB_num_rows - serakfalcon - 03-29-2014, 03:40 PM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)