/* Get all the articles for one author by using the author relation define in Articles */
$dataProvider = new ActiveDataProvider([
'query' => Articles::find()->with('author')->where(['Name'=>'Arno Slatius']),
]);
There is no column ‘Name’ in Articles table. There is column ‘Name’ in author table.
When I use with() I got error, that there is no ‘Name’ Column in Articles table.
When I use joinWith It work fine.
Is example in above article OK?
I’m afraid I cannot put where clause on Column from relational table when using “with(‘relation_name’)”.
I think I can put where clause on Column from relational table whe I use joinWith().
Can anyone confirm?
Things written in below article explains why do I have problems with above example.
“with()” doesn’t join the related table. It executes the 2nd query to fetch the records in the related table after the 1st query has fetched the records in the main table.
Thanks for pointing it out. Not sure how that ever made it there since I used working code.
I’ve reported it back to SitePoint. It’s been quite some time since it was posted and since I did anything for them. Not sure if and when they’ll fix it.