PDO: difference between rowCount () and SQL COUNT (col)

I'm just curious to know if it is better to use a class method of rowCountthe PDO class instead of SQL COUNT(col_name)to count the number of rows.

Is there any recommended situation for each of them?

0
source share
2 answers

One big difference? This disclaimer from the manual pagerowCount :

If the last SQL statement executed by the associated PDOStatement was a SELECT statement, some databases may return the number of rows returned by this statement. However, this behavior is not guaranteed for all databases , and portable applications should not be relied on.

Accent added.

, COUNT(). , , , / , , PDO rowCount, , , .

+1

rowCount, . COUNT() , mysql , .

0

All Articles