Reputation: 26825
I have a PHP script which selects a code from an InnoDB table and dishes it out to a user. Once it's selected it, it goes back and updates the table.
Partial code:
$read = "SELECT code FROM codes WHERE someCondition = true"
Then:
$update = "UPDATE codes SET status = 'assigned', timeAssigned = NOW() WHERE someCondition = true"
How do I go about using InnoDB's locking to do this a bit more robustly and prevent two users getting the same codes?
Upvotes: 2
Views: 2208