Well, let's say the bank_account table. There is a line called money . It has 2000 meanings. And we have two people trying to withdraw this money, let them do it. So is it possible that they will do this at the same time? For instance. there is a ready code:
$all_money = get_value('money', 'bank_account); //lets suppose thats a function how we get value money from bank_account table if($all_money > 0) { //here is a code where those money are being withdrawed from bank_account and inserting into the person account }
If these two people get the value 2000 at the same time, this means that this if($all_money > 0) item will be completed and both players will receive 2000, and bank_account will have -2000 money. So is this possible? If so, how can I protect him? Thanks.
source share