I have a Home model that links to a Realtor model on Home.realtor_num = Realtor.num. I have an Office model linked to the Realtor model on Realtor.office_num = Office.num.
Suppose I want easy access to Office.name in the result set of a find on the Homes table. Is there an easy way to specify the above relationship, such that $home['Office']['name'] will contain the data I'm looking for?
If you have correctly setup associations in you models:
- you can use containable behavior,
- you can access Office model from HomeController:
$this->Home->Realtor->Office->find(...)
精彩评论