protected function beforeSave() { if(parent::beforeSave()){ if($this->isNewRecord){ $this->create_time = date('y-m-d H:m:s'); $this->create_user_id = Yii::app()->user->id; $this->status_id = '0'; }else{ $this->update_time = date('y-m-d H:m:s'); $this->update_user_id = Yii::app()->user->id; } return true; }else{ return false; } }