This is a database, not a PHP question. Different databases have different
locking/buffering schemes. So which are you using, and what do the
documents say about locking? Do they lock records or pages?
Generally you never attempt to lock a record until you are ready to write
to it. In general terms, if this is a record that would be hit by a lot of
users, here's a fairly foolproof method:
Establish a loop which checks to see if the record is locked. This avoids
failure of attempting to lock an already locked record. You may have to
provide for timing out if the record is never freed.
When record becomes free, lock it.
Execute your write.
Unlock the record.
On the other hand.
Hope this helps - Miles
PS You almost never lock a record for a read.
At 01:47 PM 4/18/01 +0200, Nicolas Guilhot wrote:
>How can I avoid two or more users to update the same record at the same time
>Ideally, I would like to lock the record when a user open it for
>modification. So if another user try to open the same record he'll be warned
>or get record values as read only. Is this possible and how to do it with
>PHP ?? How can I know that the user that has locked the record has finished
>with it, if he never commits his changes ? Is there an FAQ about this ?
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]