What is the best method to make sure two people don't edit the same row on my web app?

后端 未结 6 1952
一生所求
一生所求 2020-12-29 08:57

I have a PHP/jQuery/AJAX/MySQL app built for managing databases. I want to implement the ability to prevent multiple users from editing the same database row at the same ti

6条回答
  •  再見小時候
    2020-12-29 09:17

    Don't try to prevent it. Let them decide what to do in the case of an edit conflict.

    Add a timestamp to the table. Compare the timestamp of when the row was retrieved with the current timestamp. Make them aware of changes between their load and their save, and let them decide what action to take.

    So yeah, number 3.

提交回复
热议问题