I messed with this subject for some time now. To the best of my knowledge there is no optimistic locking in Yii v1.x.
Having some sort of solution for concurrency problems is a must in any web application besides the most trivial ones, due to the concurrent nature of a web app. I think that if Yii v2 would have some sort of solution that would be very good for alleviating Yii's value for anyone who's smart enough to appreciate this. To me, if its going to enter, it will part of the 'professional' slogan of Yii.
If it is considered, here's some suggestions:
- Do have a "StaleObjectErroeException" of some sort. Its important that application specific logic could determine what to do in the case of stale object being attempted saving. In some cases the logic will be to try several times and then fire a more 'conventional' exception (e.g. CHttpException). In other cases the logic would be to ignore this exception as present the user with the same "thank you for doing this or that" message.
- Its important to have the optimistic locking in the 'standard' API calls like save() or update() as those are used for example if beforeSave() is desired (kind of like the full fledged API methods, contrary to using the aux methods like updateByPk()).
I am aware of this forum thread and also initiated during my research on optimistic locking that forum thread. Both are relevant.