_getQuery(); $dataProvider = new ActiveDataProvider(array( 'query' => $query, )); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $this->_bindQueryCondition($query); if ($this->query && !empty($this->_filterFields)) { $conditionArray = array(); foreach ($this->_filterFields as $field) { $conditionArray[] = $field . ' LIKE "%' . strtr($this->query, array('%' => '\%', '_' => '\_', '\\' => '\\\\')) . '%"'; } if (!empty($conditionArray)) { $query->andWhere('(' . implode(' || ', $conditionArray) . ')'); } } return $dataProvider; } protected function _bindQueryCondition(ActiveQuery $query) { return $this; } protected function addCondition(ActiveQuery $query, $attribute, $partialMatch = false) { $value = $this->$attribute; if (trim($value) === '') { return; } if ($partialMatch) { //$value = '%' . strtr($value, array('%' => '\%', '_' => '\_', '\\' => '\\\\')) . '%'; $query->andWhere(array('like', $attribute, $value)); } else { $query->andWhere(array($attribute => $value)); } } /** * @throws \Exception * @return ActiveQuery */ protected function _getQuery() { throw new Exception('Method _getQuery() must be overwrite'); } }