tad80 / optimisticlock
CakePHP 行为插件,用于为关系型数据库管理系统(RDBMS)实现乐观锁。
1.0.5
2015-04-23 08:30 UTC
Requires
This package is not auto-updated.
Last update: 2024-09-24 03:54:26 UTC
README
CakePHP 行为插件,用于为关系型数据库管理系统(RDBMS)实现乐观锁。
用法
最简单的方法是在您的模型中加载此行为。
class Post extends AppModel { public $actsAs = array('OptimisticLock.OptimisticLock'); }
您可以选择要比较的字段以及在Model::validationErrors中显示的错误消息。默认值将如下所示。
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和修改时间戳。
$this->Html->form->input('Post.id', array('type' => 'hidden')); $this->Html->form->input('Post.modified', array('type' => 'hidden', 'name' => 'data[Post][opt_modified]'));