Any support for optimistic locking in CakePHP?

I'm just starting out with CakePHP and I can't seem to find support for implementing an optimistic locking scheme. The closest I could find was a comment on this CakePHP post saying it was not supported in June 2008.

Does anyone know if this has changed, or has someone posted an extension or tutorial on how to implement it yourself?

For a description of optimistic locking, see this answer .

+1


source to share


3 answers


Tadashi Nakamura has posted the OptimisticLock behavior on GitHub. This is not entirely perfect, because before writing the changed record, it queries for the last modified date. This gives you the ability to either automatically overwrite other custom changes or get stuck. When I tried to write this behavior, I wanted to include the last modified date in the update where clause and fail if the affected rows are null. At that time, there was no support for adding an additional condition to the update request . I haven't used PHP lately, so I don't know if this has changed.



0


source


Not in the core, and after a quick google it doesn't appear that someone is sharing a behavior if they created it. That would be my suggested tactic.



+4


source


In the book " Practical CakePHP Projects " in Chapter 10, you will find the code to create your own magic fields. One of them is the optimistic blocking field. I haven't tried it yet, but it actually looks pretty good.

+2


source







All Articles