public function search($params) { $query = new \yii\db\Query(); $dataProvider = new ActiveDataProvider(['query' => $query->from(IisAccessLog::tableName()), 'pagination' => ['pageSize' => 50]]); $query->orderBy('Id desc'); $this->load($params); if (!$this->validate()) { return $dataProvider; } if ($this->date_reg) { $this->start_date = $this->date_reg; $this->end_date = date('Y-m-d 00:00:00', strtotime('+1 day', strtotime($this->start_date))); } $query->andFilterWhere(['Ip1' => $this->Ip1]); $query->andFilterWhere(['>=', 'date_reg', $this->start_date]); $query->andFilterWhere(['<', 'date_reg', $this->end_date]); $query->orderBy('Id desc'); return $dataProvider; }
private static function batchSaveIisAccessLog($access_log_arr) { if (!empty($access_log_arr)) { $command = \Yii::$app->db->createCommand(); $command->batchInsert(IisAccessLog::tableName(), ['RequestTime', 'ServerIp', 'RequestType', 'CsUriStem', 'CsUriQuery', 'ServerPort', 'CsUsername', 'ClientIp', 'UserAgent', 'System', 'Browser', 'Status', 'SubStatus', 'ScWin32Status', 'TimeTaken'], $access_log_arr); $command->execute(); } }