Is it ok to use mysql_affected_rows to get the number of rows affected while doing an update by a user? What if there are several users updating their passwords and I need to know if each users update was successful or not. So if 3 users did updates simultaneously, mysql_affected_rows might return 2 even if one users update was not successful. Is that how it is? I cannot test with multiple users simultaneously. How safe is this.
Share
It’s safe. It only returns data about the last query in your own connection.
PHP documentation (thanks to Fluffeh):
Since it’s a thin wrapper over MySQL C API, we can also check that:
It’s not explicitly said anywhere as far as I can see, but it does take the connection identifier and it seems that the general pattern is that all the functions return data about the specific connection:
Anyways, it would be pretty unusable if you could not be sure whether the result you obtained is yours or not.