TimestampBehavior::className(), 'attributes' => [ # 创建之前 ActiveRecord::EVENT_BEFORE_INSERT => ['create_at'], # 修改之前 // ActiveRecord::EVENT_BEFORE_UPDATE => ['update_at'] ], #设置默认值 'value' => $_SERVER['REQUEST_TIME'] ] ]; } protected function QueryFind() { return self::find(); } public function FindByUnid($id) { return $this->QueryFind()->andWhere(['unid'=>$id])->orderBy(['create_at'=>SORT_DESC])->one(); } public function Record($input) { $this->uid = $input['uid']; $this->hid = $input['hid']; $this->operation_type = $input['operation_type']; $this->content = $input['content']; $this->create_at = $_SERVER['REQUEST_TIME']; $this->unid = $input['unid']; return $this->save(false); } }