[Fwd: Re: DB access and sessions]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Uups, forgot to send my answer to Bret to the list too.

Sabine
--- Begin Message ---
Hello Bret,

I think Terences solution is good, if you have a lot of concurrency on your documents. But if the concurrency is less and it is unlikely that 2 people edit the same document at the same time, I'll prefer a more simple solution.

Create a field edit_counter in your database-table (perhaps edit_user + time are a good idea too for information purpose). Then, in the moment, one wants to save his changes, first check, if the counter as changed (which means someone else edited the doc). If not, save his changes. If so, throw his changes into the waste paper basket, refresh his form with the changes of the other person and let him make his changes again on this basis. Or, the more polite version, show him his and the other persons changes and let him decide.

Best regards
Sabine


Bret Walker schrieb:

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




--- End Message ---
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux