Doubt about Active Record

Hello

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’.

http://www.yiiframework.com/doc-2.0/guide-db-active-record.html#joining-with-relations

Very good. Works fine. Thanks