There are many conflicting statements around. What is the best way to row count using PDO in PHP ? Before using PDO, I just simply used mysql_num_rows. Select the number of rows using PDO. Comments (1) When you need to count rows that match some criteria in your database, under no circumstances you should select the actual rows and then use rowCount()! Rowcount to get number of rows changed or affected by Query WE can use rowcount() to know number of rows or records affected by the latest sql statement involving any Delete , update , insert command.

This is a tutorial on how to count the number of rows in a MySQL table using PHP ’s PDO object. For this example, we will assume that we want to count the number of records in a MySQL table called “users”. To do this, we will prepare an SQL COUNT statement and execute it using PDO. The number of rows adde delete or changed.
Support for PDO was added in version 2. Microsoft Drivers for PHP for SQL. Although PDO apparently has all means to count the number of rows returned from a select query for mysql, what is more important is that there is no use for such a function in the first place. Using SQL_CALC_FOUND_ ROWS and FOUND_ ROWS ( ) will NOT trigger a race condition on MySQL, as that would pretty much defy their entire purpose.



