Re: Re[2]: [PHP-DB] Table locking

2004-07-15 Thread Tim Van Wassenhove
In article <[EMAIL PROTECTED]>, Emre Erdogan wrote:
> Hi...
> 
> I want to say some words about the "Table Locking" problem.
> 
> I had a problem something like this one, I find solution for this by locking
> only the item that will updated. I added two areas one that has a value 0 or
> 1 giving it is currently used by someone, and second time it is started to
> use, default 0. When someone trying to update the item, first area has the
> value 1 and the second has the current time. After update completes, ifrst
> has the value 0, and second also 0.

I think one row will satisfy, namele a timestamp last_update.

If you generate a form for the user to update the values of the current
record, just add the timestamp as a hidden value. If the user submits
the updated values compare the submitted last_update with the value in
the database. If they are equal, perform the update (and change the
value for last_update). If they are not equal, somebody else has changed 
the values in the meantime and the update should not be executed.

If you are looking for other synchronization techniques you should have
a look at the algorithms by Dekker and Peterson etc... Every website on
computer algorithms will know how they work...

-- 
Tim Van Wassenhove 

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



Re: Re[2]: [PHP-DB] Table locking

2004-07-15 Thread emre erdogan
Hi...

I want to say some words about the "Table Locking" problem.

I had a problem something like this one, I find solution for this by locking
only the item that will updated. I added two areas one that has a value 0 or
1 giving it is currently used by someone, and second time it is started to
use, default 0. When someone trying to update the item, first area has the
value 1 and the second has the current time. After update completes, ifrst
has the value 0, and second also 0.

So if someone tries to update the area first system will chack and if
someone is updating the item it will not give permission for this. Also it
will chack the time if update is out of time (ex:more than 15 minutes) it
will reset the time section and will give permission to update this item.

This will provide people to see all other table elements ather then the
updated.

It worked for me...

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