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
You'll have to implement a checkout/checkin system. The first user to
check out the document gets to do whatever he wants with it until he
checks it back in.
Yes, that means that if he forgets to do this others are screwed, but you
could add a way for other users to forcibly remove the first's checkout
removing all changes.
The problem is the web is stateless so how do you know if a user is
activiely editing the document? You can't really... he might have gone to
lunch, he might just be taking his time.
You might get around some of it by using a hidden frame and some
the client is still there. That doesn't solve the gone to lunch and left
my browser open issue though...
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php