db\BaseActiveRecord afterSave()

afterSave() public method

This method is called at the end of inserting or updating a record.

The default implementation will trigger an EVENT_AFTER_INSERT event when $insert is true, or an EVENT_AFTER_UPDATE event if $insert is false. The event class used is yii\db\AfterSaveEvent. When overriding this method, make sure you call the parent implementation so that the event is triggered.

public void afterSave ( $insert, $changedAttributes )
$insert boolean

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

$changedAttributes array

The old values of attributes that had changed and were saved. You can use this parameter to take action based on the changes made for example send an email when the password had changed or implement audit trail that tracks all the changes. $changedAttributes gives you the old attribute values while the active record ($this) has already the new, updated values.

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

Please login to continue.