Ok so this is one of the last things I need to know before I can reprogram everything in Yii2.
We always had this function in models:
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('title_id',$this->title_id);
$criteria->compare('subjects_id',$this->subjects_id);
$criteria->compare('main',$this->main);
return new CActiveDataProvider(get_class($this), array(
'criteria'=>$criteria,
));
}
Unfortunately I have not yet found a good way of replacing this, namely because compare no longer exists.
The only way I have found was to create middle tier models to replicate the behaviour.
I think with Yii2 you will have 2 separate model classes as you generate your CRUD - one for create/update/delete and the other for search. So if you had a model named Post in Yii 1.x… you will have something like Post and PostSearch generated in Yii2.
So now, depending on your application design, you may want to check, how you can use Gii to generate all of your SearchModels, and then alter your code to point to the Search model. Not sure how challenging this is for you. You may want to see if you can have a BaseController Class and extend that through parameters.