Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DB_num_rows
03-28-2014, 05:22 PM,
#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.
Reply


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

Forum Jump:


Users browsing this thread: 1 Guest(s)