加载中...

Yii-数据模型-beforeSave保存数据前自动处理


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;
	}
}


还没有评论.