Re: table locking ... not required ?

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

 



In article <20040709082212.856.qmail@xxxxxxxxxxxx>, Torsten Roehr wrote:
> Add an int field oca to your table. Increment this value on every update.
> When someone edits a row, read the value and put it into a hidden field.
> Then on update check for condition WHERE oca = $ocaFromHiddenField AND id =
> $id etc. Check the affected rows of your update. If it is 0 someone else has
> updated between the start and end of your editing (because oca will have
> been incremented). Then tell your user that someone has just made a change
> to the record set he is editing and he should abort and start again.

update 'rows you would update anyway' and 'oca=oca+1' where 'regular stuff'
and 'oca=$ocaFromHiddenField'

If you don't update the 'rows you would update anyway' and 'oca=oca+1'
at the same time you run again into concurrency problems. 


-- 
Tim Van Wassenhove <http://home.mysth.be/~timvw>

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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux