Reputation: 92
I am not entirely sure how to word this, however my example should help. I have encountered the following problem:
There are 3 bidders in an auction:
After all these scripts have finished executing, bidder 1 gets refunded twice and bidder 2's bid has just disappeared.
I use mysql to store information about the bids, and php to execute the requests.
I have heard Database Transactions might help, but I am not entirely sure how.
Upvotes: 3
Views: 158
Reputation: 62330
Your second script consists of two interaction with the database. By default, each DB statement is executed as a single transaction. In your case, you need to do both interaction of the second script as a single transaction. This prevents the third script (that should also run as a single transaction) from starting before the second script finished. See PHP + MySQL transactions examples for an example on doing multi-statements transaction with php and mysql.
Upvotes: 3