class User extends CActiveRecord { public function afterSave() { Yii::log('User record saved with id:'.$this->id, 'info', 'application.models.User'); parent::afterSave(); } }
class Post extends CActiveRecord { public function afterSave() { if ($this->isNewRecord) { // send email notification to author Yii::app()->mailer->send(array( 'to'=>$this->author->email, 'subject'=>'New Post Created', 'body'=>'Your post with title "'.$this->title.'" has been created.', )); } parent::afterSave(); } }The package library for this code examples is Yii Framework.