Jump to content

Recommended Posts

I have a new problem on the horizon regarding multiple users accessing and editing the same data. I think i have solved it, but not sure if i've got the theory behind it sorted. Here's what i have:

 

The scenario:

Multiple users can view different sentences stored in a table.

The same multiple users can also edit the said sentences.

The table containing the sentences looks a little like this:

 

TableA contains four fields:

Field1= sentenceID (this contains a unique ID for the sentence)

Field2 = sentence  (this field contains different sentences in each row)

Field3 = beingEdited  (this field either contains the user ID of the person editing the sentence, or a 0 indicating that the sentence is not being edited)

Field4 = timeEditBegan (this field contains a time stamp of when the user started editing the sentence)

 

If userID 2534 starts to edit a sentence of sentenceID 54. What i don't want is for a different user, of ID (EG 1223) to start editing the same sentence. This would result in userID 2543 saving their edit, only to see the same comment changed almost instantly by userID 1223. And also it would mean userID 1223 would not see userID 2534's edit (ie their edits maybe the same, meaning two people editing the same comment is a waste of time)

 

To attempt to get around this:

When userID 2534 loads up the edit page for sentenceID 54, it also sets field3 and 4 for that sentence ID to 1 and time() accordingly.

This means that if the other user decides they want to edit the same comment at the same they can't as there is a 1 in field3.

To then prevent the said comment from remaining permanently in this 'edit' state (eg if a user loaded the edit but then lost internet connection), the second user can see how long the sentence has been in edit state, thus if the edit state had been for say more than 30minutes they can override this and edit the comment themselves.

 

 

I hope this is clear. I understand i can do this with cron and possibly ajax, but i think if this works then there is no need to involve those too.

 

Any thoughts would be very much appreciated.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.