I have a query like this:
UPDATE persons SET processing = :processing WHERE processing IS NULL LIMIT 1
What if the script gets called twice at the exact time to execute this query? Is it possible that it just updates the same row twice?
I have a query like this:
UPDATE persons SET processing = :processing WHERE processing IS NULL LIMIT 1
What if the script gets called twice at the exact time to execute this query? Is it possible that it just updates the same row twice?
It will execute it twice, atomically. If processing
is changed to not null, then the second operation in the queue will do nothing.
If you are thinking about the 'rows_affected' value, it will say 0 rows affected the second time, that is unless you change a connection parameter that tells it to return any rows found rather than actually modified.
Re-interpreting your question, if you have a table of multiple processing
entries, with multiple being NULL, then no it will not update the same one, two of them will be set.