开发者

CakePHP model associations via an intermediary table?

开发者_如何学Go

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:

  1. you can use containable behavior,
  2. you can access Office model from HomeController: $this->Home->Realtor->Office->find(...)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜