Re: need help with table lock - could this be performed with mysql commands or do I to write my own PHP function

From: Date: Sun, 10 Aug 2003 16:30:15 +0000
Subject: Re: need help with table lock - could this be performed with mysql commands or do I to write my own PHP function
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-159034@lists.php.net to get a copy of this message
* Thus wrote anders thoresson (listor@thoresson.net): > set_lock($table_name, $row_id), check_lock($table_name, $row_id) and > release_lock($table_name, $row_id). Whenever an editor opens some content > for editing, check_lock() will be called to se if table_lock contains a row > with the same table_name and row_id. If, the content isn't loaded and the > editor is told that someone else is working on the content, and are asked > to try again later. If not, set_lock() is called to make sure that no other > editor opens the content before it's saved and release_lock() is called, > which will remove the line from table_lock again. What happens when the user doesn't finish editing or the browser simply crashes on him? If you do use this method, it needs to be atomic. if two users access the page at the same time they both will pass the check_lock() function but only one will pass set_lock(), if the database constraints are enforced. You'd want something like: if (! set_lock() ) { // table is already locked } else { // we have the lock } Curt -- "I used to think I was indecisive, but now I'm not so sure."

« previous php.general (#159034) next »