Doubt about Active Record


I need to serach data on my table, but on my Active Record I use a relation, and the field that I need to do a search is on relation table. I tried it:

$test = MyTable1::find()->with('idmytable2')->where('idmytable2.field like :query')->addParams([':query'=>'%'.$search.'%'])->limit($limit)->offset($offset)->all();

But it: idmytable2.field like :query dont work. How can I fix it? Is it possible on active record?

You could use ‘joinWith’ instead of ‘with’.

Very good. Works fine. Thanks