backend/models/search/PreferencesSearch.php
/**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
Creates data provider instance with search query applied
@param array $params


Creates data provider instance with search query applied @param array $params
public function search($params)
    {
        $query = Preferences::find()
            ->where('pref_category != :CATEGORY_HIDDEN', [
                'CATEGORY_HIDDEN' => self::CATEGORY_HIDDEN
            ])
            ->indexBy('pref_id');
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'sort'=> [
                'defaultOrder' => ['pref_id'=>SORT_DESC],
                'attributes' => [
                    'pref_id',
                    'pref_key',
                    'pref_category',
                ]
            ],
        ]);
        $this->load($params);
        if (!$this->validate()) {
            return $dataProvider;
        }
        $query->andFilterWhere([
            'pref_id' => $this->pref_id,
            'pref_category' => $this->pref_category,
        ]);
        $query->andFilterWhere(['like', 'pref_title', $this->pref_title])
              ->andFilterWhere(['like', 'pref_key', $this->pref_key]);
        return $dataProvider;
    }
public function search ( $ params ) { $ query = Preferences :: find ( ) -> where ( 'pref_category != :CATEGORY_HIDDEN' , [ 'CATEGORY_HIDDEN' => self :: CATEGORY_HIDDEN ] ) -> indexBy ( 'pref_id' ) ; $ dataProvider = new ActiveDataProvider ( [ 'query' => $ query , 'sort' => [ 'defaultOrder' => [ 'pref_id' => SORT_DESC ] , 'attributes' => [ 'pref_id' , 'pref_key' , 'pref_category' , ] ] , ] ) ; $ this -> load ( $ params ) ; if ( ! $ this -> validate ( ) ) { return $ dataProvider ; } $ query -> andFilterWhere ( [ 'pref_id' => $ this -> pref_id , 'pref_category' => $ this -> pref_category , ] ) ; $ query -> andFilterWhere ( [ 'like' , 'pref_title' , $ this -> pref_title ] ) -> andFilterWhere ( [ 'like' , 'pref_key' , $ this -> pref_key ] ) ; return $ dataProvider ; }
Creates data provider instance with search query applied
 @param array $params
Creates data provider instance with search query applied @param array $params
// uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1');