join, joinWith and Definitive Guide

A the bottom of

there is "Further reading" and there is link to

there is an example:

/* 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.

Yes, you are right.

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

Lazy Loading and Eager Loading (

"joinWith()" joins the related table in the 1st query. So you can filter and/or sort the result by a column in the related table.

Joining with Relations (

Where is best place to report this bug in Guide?

Since the article is not under the control of yii developers, you should report the bug to the author of the article, Arno Slatius.

Guilty party reporting in.

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.