PHP / MySQL - how to prevent two requests *Update

前端 未结 5 1323
清酒与你
清酒与你 2020-12-23 22:02

I have some question ... example: a user will buy something for his USD

  1. Check his USD Balance
  2. Deduct the USD from his account
  3. Make an Order -
5条回答
  •  失恋的感觉
    2020-12-23 22:31

    This is how I used to do it many years ago..

    results = query("UPDATE table SET value=value-5 WHERE value>=5 AND ID=1")
    if (results == 1) YEY!
    

    (Is this still a reliable method?)

提交回复
热议问题