Home  >  Article  >  Backend Development  >  Can the rowCount method of php's pdo::statement return the functions affected by the select statement?

Can the rowCount method of php's pdo::statement return the functions affected by the select statement?

WBOY
WBOYOriginal
2016-08-25 10:37:221201browse

As shown in the picture below:

Can the rowCount method of php's pdo::statement return the functions affected by the select statement?

Can the rowCount method of php's pdo::statement return the functions affected by the select statement?

Reply content:

As shown in the picture below:

Can the rowCount method of php's pdo::statement return the functions affected by the select statement?

Can the rowCount method of php's pdo::statement return the functions affected by the select statement?

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.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn