db\BaseActiveRecord beforeSave()

beforeSave() public method

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:

public function beforeSave($insert)
{
    if (parent::beforeSave($insert)) {
        // ...custom code here...
        return true;
    } else {
        return false;
    }
}
public boolean beforeSave ( $insert )
$insert boolean

Whether this method called while inserting a record. If false, it means the method is called while updating a record.

return boolean

Whether the insertion or updating should continue. If false, the insertion or updating will be cancelled.

doc_Yii
2016-10-30 16:56:38
Comments
Leave a Comment

Please login to continue.