I’m trying to have this same code in Yii 2.x but it’s not working. This is what I used in Yii 1.x

$dataProvider = new CActiveDataProvider('ManifestOrders',array('criteria'=>array('condition'=>"manifest_id = $id",'order'=>'job_id'), 'pagination'=>false));

The ManifestOrder has a relation to the Job table

    public function getJob()


        return $this->hasOne(Job::className(), ['id' => 'job_id']);


So my dataprovider needs to contain all the fields that Job class has.

In Yii 2, ActiveDataProvider takes an instance of Query or ActiveQuery which should query the model.

$query = ManifestOrder::find()


    ->where(['manifest_id' => $id]);

$dataProvider = new ActiveDataProvider(

    'query' => $query,

    'pagination' => false,

    'sort' => [

        'defaultOrder' => [

            'job_id' => SORT_ASC,




‘with’ will eagerly load the ‘job’ relation.

If ‘manifest_id’ is an attribute of Job, then you have to join the ‘job’ relation:

$query = ManifestOrder::find()


    ->where(['job.manifest_id' => $id]);



Yii 2 doesn’t have CDbCriteria anymore. You can use ActiveQuery and Query in all the places where database is involved.

ActiveRecord - Quering Data