I am just wondering what the definitive answer to this question is. The PHP PDO documentation warns that PDOStatement->rowCount
cannot be relied up to return the number of rows "affected" with a SELECT
statement. And yet I find that this continues to work perefectly with mySQL + PHP version after version. Perhaps there is an issue when using another DB but if I don't ever want to migrate to another DB should I really care?
Asked
Active
Viewed 1,558 times
1

Mahmoud Gamal
- 78,257
- 17
- 139
- 164

DroidOS
- 8,530
- 16
- 99
- 171
1 Answers
1
Yes, you should still care about the usage of that method. It's not just the database, but PHP itself can be a problem.
If you want to play it safe, it's better if you just issue a SELECT COUNT(*)
instead.

Community
- 1
- 1

Kemal Fadillah
- 9,760
- 3
- 45
- 63
-
Thank you! SELECT COUNT it is then! – DroidOS Sep 27 '12 at 03:06
-
I'm not sure running a query twice and assuming the same results were returned each time is safe exactly. – Sep 05 '13 at 10:45