TimestampBehavior::className(), 'attributes' => [ # 创建之前 ActiveRecord::EVENT_BEFORE_INSERT => ['create_at'], # 修改之前 // ActiveRecord::EVENT_BEFORE_UPDATE => ['update_at'] ], #设置默认值 'value' => $_SERVER['REQUEST_TIME'] ] ]; } public function RecordQuery($arr = []) { $query = self::find(); $query->andWhere(['id'=>$arr['id']]); $query->andWhere(['ip'=>$arr['ip']]); $query->andWhere(['type'=>$arr['type']]); return $query->one(); } public function addRecord($arr) { $this->id = $arr['id']; $this->ip = $arr['ip']; $this->type = $arr['type']; return $this->save(); } }