locking a mysQL row

From: Date: Tue, 11 Sep 2001 01:48:16 +0000
Subject: locking a mysQL row
Groups: php.general 
Request: Send a blank email to php-general+get-66844@lists.php.net to get a copy of this message
Hi all, I'm currrently developing a dynamic, user-added content site. The thing is, content can be added and edited my TWO people.. the original writer, and the editor. So, my problem is, if the editor/user makes an edit to content whilst the other is also attempting to do so, one of them will get overwritten. This isn't the end of the world, but it's a bit of a problem i'd like to clear up. So, my initial thought was to add a new column to the code "locked" with a time that the code can be re edited. 1. when the user requests to edit the content, the program first makes sure any "locked" time has expired. 2. he/she is given a time limit (say 10 minutes) to edit and re-submit, during which time the annother user cannot edit or change the content. 3. when the user submits the edited content, the locked timestamp is deleted, so that the content can be re-edited earlier than the 10 minutes. 4. if the user submits after the 10 minutes, they are rejected, since the content may have been edited by annother user. Does this seem like a good move? Can any one offer any firther tips or a smarter way to do this? Thanks Justin French

« previous php.general (#66844) next »