Home >Backend Development >PHP Tutorial >Can the rowCount method of php's pdo::statement return the functions affected by the select statement?
As shown in the picture below:
As shown in the picture below:
Affected refers to the number of rows that have been changed. SELECT query will not change the content of the rows.
http://php.net/pdo
In pdo, use count to calculate the result set array to get the number of rows queried by select. rowCount() stores the number of affected (changed) rows in the query (insert/update/delete) .
http://php.net/mysqli
In mysqli, num_rows (valid only when buffering query is enabled) stores the number of rows queried by select, and affected_rows stores the affected (changed) rows in the query (insert/update/delete) Number of lines.
It is worth noting that during update, if the updated content is the same as the original content, mysqli's affected_rows and pdo's rowCount() will also return 0.