From: Cook, M. <MEC@Stowers-Institute.org> - 2008-05-23 22:06:38
|
Is there a strategy to using mySQL timestamps to achieve optimistic row locking? Basically, in a web app, I would like ActiveRecord to ensure that the row that is getting updated is the same row that was selected for editting by the user, by initially selecting a timestamp column on the table that has been declared as DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP when a (single row) update is done, the rows primary key and the old selected timestamp would be used to select the row to update. If ROW_COUNT() is not 1, then the row has been changed (or deleted) somehow else. Any approaches out there? Regards, Malcolm Cook |