This method is called at the beginning of inserting or updating a record.
The default implementation will trigger an EVENT_BEFORE_INSERT event when $insert is true, or an EVENT_BEFORE_UPDATE event if $insert is false. When overriding this method, make sure you call the parent implementation like the following:
这个方法会在插入或者是更新的时候进行调用
当$INSETRT为真的时候甚至是错误的时候 默认会触发EVENT_BEFORE_INSERT事件或者是
EVENT_BEFORE_UPDATE事件 当重写这个方法的时候 确保你调用了他的借口如下所示:
public function beforeSave($insert)
{
//如果没有继承父类的方法 就是错误
if (!parent::beforeSave($insert)) {
return false;
}
// ...接下来写自定义的代码...
return true;
}