AR accesing a column in a third relationship table

I have these three tables

ad

user

zip_code

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 user.id = 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:

$results->zip_code->state

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

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

Thanks!

See author.profile in http://www.yiiframework.com/doc/guide/database.arr

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.