I have three tables *Countries, Cities* and *Addresses*. Their relationship 
is Countries hasMany Cities, Cities hasMany Addresses. So Its something 
like this Countries->Cities->Addresses.

If I want to get all addresses in a certain city I can do it like this

$this->paginate = [
        'contain' => ['Cities']
    ];
    $this->set('addresses', $this->paginate($this->Addresses));

If I want to get all Cities in a certain Country I can do like that as well.

*What I want is I want to get all Addresses in a Certain Country. *If 
there's new way by modifying above code or using ORM it would be great.

Note: Addresses *does not* contain foreign key for Countries, instead its 
in the Cities.

Possible query would be: SELECT a.*, c.* FROM countries a LEFT JOIN cities 
b ON a.id=b.country_id LEFT JOIN addresses c ON b.id=c.city_id

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Reply via email to