AR accesing a column in a third relationship table

I have these three tables




ad has many user

user has one zip_code

I am trying to access a zip_code column with this Active Record query:

$criteria->join = 'inner join user on = ad.user_id inner join zip_code on zip_code.zip_code = user.zip_code ';

$results = ad::model()->with( ‘user’)->findAll($criteria);

when I call:


I don’t get an error, I get nothing, blank.

So, is it possible to access a column in zip_code from ad?


See author.profile in

Or try $results->user->zip_code->state

The ‘join…on’ clause is already in the SQL statement from the relationship definition. You should not have to specify a join clause for the criteria.