事件主要分为前置事件before和后置事件after
class User extends Model
{
CONST TABLE = 'users';
public function events()
{
return [
'beforeGet => function ($model) {
// 这里可以修改 参数的值
// 如果返回 false sql将终止执行
},
'afterGet' => function (& $result, & $arg = null) {
},
'beforeUpdate' => function ($model) {
},
'afterUpdate' => function (& $result, & $arg = null) {
},
'beforeDelete' => function ($model) {
},
'afterDelete' => function (& $result, & $arg = null) {
},
'beforeInsert' => function ($model) {
},
'afterInsert' => function (& $result, & $arg = null) {
},
];
}
}
~~~
`