How do you manage concurrent access to forms?

前端 未结 8 1324
离开以前
离开以前 2020-12-17 15:27

We\'ve got a set of forms in our web application that is managed by multiple staff members. The forms are common for all staff members. Right now, we\'ve implemented a locki

相关标签:
8条回答
  • 2020-12-17 16:17

    Do something similar to what is done in many version control systems. Allow anyone to edit the data. When the user submits the form, the database is checked for changes. If the record has not been changed prior to this submission, allow it as usual. If both changes are the same, ignore the incoming (now redundant) change.

    If the second change is different from the first, the record is now in conflict. The user is presented with a new form, which indicates which fields were changed by the conflicting update. It is then the user's responsibility to resolve the conflict (by updating both sets of changes), or to allow the existing update to stand.

    0 讨论(0)
  • 2020-12-17 16:19

    The simplest method is to format your update statement to include the datetime when the record was last updated. For example:

    UPDATE my_table SET my_column = new_val WHERE last_updated = <datetime when record was pulled from the db>
    

    This way the update only succeeds if no one else has changed the record since the last read.

    You can message to the user on conflict by checking if the update suceeded via a SELECT after the UPDATE.

    0 讨论(0)
提交回复
热议问题