I'm just starting out with CakePHP, and I can't find any support for implementing an optimistic locking scheme. The closest I could find was a comment on this CakePHP blog post saying that it wasn't supported in June 2008.
Does anyone know if that has changed, or if someone has published an extension or a tutorial on how to implement it yourself?
For a description of optimistic locking, see this answer.
Not in the Core, and after a quick google it doesn appear that anyone is sharing a behavior if they made one. That would be my suggested tactic.
In the book "Practical CakePHP Projects" on chapter 10 is some code given to make your own "Magic Fields". One of them is a field for optimistic locking. I haven't tried it yet, but it looks quite good actually.
在第10章的“Practical CakePHP Projects”一書中,有一些代碼用於制作你自己的“Magic Fields”。其中一個是樂觀鎖定領域。我還沒試過,但實際上它看起來很不錯。
Tadashi Nakamura has posted an OptimisticLock behaviour on GitHub. It's not quite perfect, because it does the query for the last modified date before writing the changed record. That leaves you open to either silently overwriting another user's changes or hitting a deadlock. When I tried to write a behaviour like this, I wanted to include the last modified date in the update's where clause and fail if the rows affected is zero. At that time, there was no support for adding an extra condition to an update query. I haven't used PHP lately, so I don't know if that has changed.