RE: [PHP] Locking and unlocking records
| From: | Williams, Olwen - SAL | Date: | Thu, 15 Jan 2004 23:27:40 +0000 |
| Subject: | RE: [PHP] Locking and unlocking records | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-174734@lists.php.net to get a copy of this message | ||
One way to do this is to keep a copy of the old record in a session
variable. When you com to write the data back read the record again and see
if it is still the same. If it is you can save the changes, otherwise give
an error saying that the data has been changed, and probably refuse to do
the update. You might like to concoct a friendlier failure than this.
Olwen Williams
olwen.williams@safeair.co.nz
-----Original Message-----
From: Jason Wong [mailto:php-general@gremlins.biz]
Sent: Friday, January 16, 2004 12:05 PM
To: php-general@lists.php.net
Subject: Re: [PHP] Locking and unlocking records
On Friday 16 January 2004 04:49, Lowell Allen wrote:
> I need to implement database record locking and unlocking. I want to
> prevent multiple users of a content management system from editing the
same
> record simultaneously, which can result in one user's edits being
> overwritten. I can use PHP to lock a record when it's opened, and unlock
it
> when it's updated or if the user goes anywhere else within the content
> management system (or logs out), but I need to account for a user leaving
> the CMS directly from the edit screen. I'm not aware of any way to do that
> other than using a Javascript onunload event to open a new window, run a
> PHP script, and close the new window onload -- very nasty and unreliable
> with pop-up blocking so popular. Can anyone suggest an all-PHP way?
There is no way to determine whether/when a user 'leaves' the edit screen.
The
best you can do is to set a timeout on the locked record. So if the person
who locked the record hasn't done anything to it for the last 10 minutes (or
whatever) then unlock the record.
--
____________________________________________________________________
CAUTION - This message may contain privileged and confidential
information intended only for the use of the addressee named above.
If you are not the intended recipient of this message you are hereby
notified that any use, dissemination, distribution or reproduction
of this message is prohibited. If you have received this message in
error please notify Safe Air Ltd immediately. Any views expressed
in this message are those of the individual sender and may not
necessarily reflect the views of Safe Air.
_____________________________________________________________________
For more information on the Safe Air Group, visit us online
at http://www.safeair.co.nz/
_____________________________________________________________________