The PHP Documentation says:
If you\'ve never encountered transactions before, they offer 4 major features: Atomicity, Consistency, Isolation and Durabili
Alas, the "without interference" needs some help from the programmer. It needs BEGIN and COMMIT to define the extent of the 'transaction'. And...
Your example is inadequate. The first statement needs SELECT ... FOR UPDATE. This tells the transaction processing that there is likely to be an UPDATE coming for the row(s) that the SELECT fetches. That warning is critical to "preventing interference". Now the timeline reads:
FOR UPDATE)(Note: This is not a 'deadlock', just a 'wait'.)