web applications - Blocking a record from editing while another user is editing the record - how? -


I am trying to add record locking to a site. This is not locking the database, where I have the process of editing the same record at the same time, but 2 users with the same record at the same time instead. Here's the situation:

I should be able to lock a record, while 1 person is editing it, so anyone can make changes to record at the same time (and therefore confusion The reason). What might happen is that the user starts recording a record, in the mean time (user saves records before A), User B starts editing the record, now the user saves records with field_a, which is a value of "A" 0001 Now user is watching and editing the older version of the B record. Then the user saves records with the value of "0002" ends with the value of the database 0002.

I can understand what happened, but for the user it is difficult to understand that the value in DB will be 0002 instead of 0001. In my case, they are using this number to record online records to another record online in the database. When this happens, they will end up with 2 records in the other system for 1 record in the online system.

In the My Idea field, enter the user's ID in the field and "Lock" the record. When 0 is not locked it is locked 0.

I think how this will work:

  • When a user clicks editing on a record, they will get locked records.
  • They will have the maximum fresh X minutes (maybe 30).
  • After saving it, the record will be unlocked.
  • To delete without lock, I need to click on "Unlock" (or similar) on the edit page I will cancel, but I want to be able to cancel them and still lock on Keep me
  • In the list of records, I will include the name of the person who has locked the record so that everyone knows.
  • The administrators will be able to remove the lock for a record, only they will be separated.
  • Add a region on each page to warn the user, which requires the current record to be unlocked when they display the number of records recorded on each page or display them Are there.
  • Add a script that is checked for the record which has been locked for more than 30 minutes and can unlock them (potentially

I am thinking that if I am missing any case which is going to create sorrow or if you have any suggestions, how to do it?

Note: I am working in PHP and MySQL And this is a web application. I do not even think that record locking in the database Required.

- In addition: To add a date field with a suggestion that was last checked out, it will terminate the script for an expired checkout. The date will be checked when the records are to be listed or restricted.

OK, you need < Em> some locking scheme

  • Associate a version number with the proper record
  • P> When trying to save a file, see the version number. If the version number is the same as what you received, you save, and then increment the version number but if the file is opened The version number is not equal to what you saved, so you have a conflict;

  • If you have a conflict, you ask the user in any way to solve it.

(This is called "optimist" because you believe that most of the time you will not have two users updating at the same time.)

< P> pessimistic version will be an area for lock. When someone opens the record for editing, check that area; If it is 0, you can edit, but then add 1 to field. When you save, decrease again 1. If this is not 0, then you refuse to edit the user.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -