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

后端 未结 6 1970
一生所求
一生所求 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:38

    As others have said it's much easier to deal with a conflicting update. What you are suggesting is called pesimistic locking. It's called thate because it's all too likely that two users will try and edit the same record at the same time.

    Is that true?

    And is it a disaster if a user has to start again, because the data they tried to update was changed by someone else.

    Locking costs, you always lock in a pessimistic scheme, so you have an overhead, and that's before you start looking at related data and such.

    Making it robust, dealing with no one can do it now coz sumfin' went wrong...

    If I had something short of editing an entire file, that needed pessimistic locking, I'd be having a look at my design, on the basis that it isn't fit for purpose.

提交回复
热议问题