|  | Posted by Terence on 08/18/05 07:55 
We use a combination of timeout and user who has locked the record in a form e.g.
 
 User A opens the form. A record id is stored in the page and the db
 record has 3 cols -> is_locked (y/n), locked_by (user_id) & locked_time
 (datetime)
 
 B then opens the form.
 If the record is locked & more then 5 minutes has passed then B's ID
 will then be updated into the table and a new locked_time set.
 
 If it's locked and within the time an error message pops up saying
 "Record locked by XYZ for another 3 minutes".
 
 If user A comes back in 10 minutes and submits, the sys checks if his
 user id is in the "locked_by" col, and then alerts him that his 5
 minutes were up and he needs to refresh.
 
 It's never let us down. If you can improve on it let me know :)
 
 Bret Walker wrote:
 > Hello-
 >
 > I'm developing a web-based system whereby users can edit documents and
 > then e-mail the documents to selected recipients.
 >
 > The "documents" are comprised of the data from several MySQL fields.
 >
 > I want to make sure that two people don't edit a document at the same time.
 >
 > My users log in via a script that starts a session.
 >
 > My initial idea was to have a field to denote file access (1 for "in
 > use" 0 for available).  The problem with this would be if a user
 > navigates to a different page or closes the browser window without
 > clicking a "save" or "close" button (which would execute a query to set
 > the in_use field to 0).
 >
 > I'm sure others have dealt with the issue of exclusive access to a MySQL
 > resource.  I've looked into InnoDB transactional support, but that
 > doesn't seem to be what I need, since I'm not overly concerned about
 > simultaneously access, just simultaneous editing.
 >
 > How can I ensure the "document" isn't accessed by two people at the same
 > time?
 >
 > Thanks,
 > Bret
  Navigation: [Reply to this message] |