public function searchReport($params) { $query = ContentType::find(); if (isset($params['per-page'])) { $pageSize = $params['per-page']; } else { $pageSize = 1; //Yii::$app->params['page_size']; } $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => $pageSize, 'params' => $params], 'sort' => ['defaultOrder' => 'tcl_id desc', 'params' => $params]]); $query->andFilterWhere(['between', 'last_update', $params['ContentType']['startDate'] . " 00:00:00", $params['ContentType']['endDate'] . " 23:59:59"]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = ContentType::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['tct_id' => $this->tct_id, 'tcl_media_type' => $this->tcl_media_type, 'tcl_priority' => $this->tcl_priority, 'tcl_support' => $this->tcl_support, 'tcl_counter' => $this->tcl_counter, 'first_update' => $this->first_update, 'last_update' => $this->last_update, 'tcl_support2' => $this->tcl_support2]); $query->andFilterWhere(['like', 'tcl_name', $this->tcl_name])->andFilterWhere(['like', 'first_user', $this->first_user])->andFilterWhere(['like', 'first_ip', $this->first_ip])->andFilterWhere(['like', 'last_user', $this->last_user])->andFilterWhere(['like', 'last_ip', $this->last_ip]); return $dataProvider; }