tad80 / optimisticlock
CakePHP behavior plugin to implement optimistic locking for RDBMS.
Installs: 39
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Type:cakephp-plugin
Requires
This package is not auto-updated.
Last update: 2024-12-17 04:49:33 UTC
README
CakePHP behavior plugin to implement optimistic locking for RDBMS.
Usage
Most simply, just load this behavior in your model.
class Post extends AppModel { public $actsAs = array('OptimisticLock.OptimisticLock'); }
You can specify which field to compare and error message shown in Model::validationErrors. Default will be like this.
class Post extends AppModel { public $actsAs = array( 'OptimisticLock.OptimisticLock' => array( 'field' => 'modified', 'message' => 'Update conflict, another user has already updated the record. Please list and edit the record again.', ), ); }
Id and modified timestamp must be sent from your form.
$this->Html->form->input('Post.id', array('type' => 'hidden')); $this->Html->form->input('Post.modified', array('type' => 'hidden', 'name' => 'data[Post][opt_modified]'));