UPDATE table SET foo = 'bar' WHERE id = 1
If you run this once, PDOStatement::rowCount() returns 1, but if you run it again (more than once), the succeeding run returns 0.
I was wondering if this is really the expected behavior? Isn’t it suppose to always return 1 since you are basically updating/affecting the same row?
rowCount()reports on the number of rows actually modified by anUPDATEstatement. If you call the sameUPDATEstatement twice, the second time there will not be any rows requiring modification (since they changed the first time). So the number of affected rows actually is 0 the second time.If you ran the same thing in the console, you would see something like the following, indicating that although a row met your criteria, its column values already were what you attempted to change them to, and hence they remain unchanged.