Model with two belongsTo associations

2010-06-07 Thread bmcelhany
Hi all, I've been working on this for a while and searching for a solution, but can't seem to get it working correctly. Let's say I have Category, Label, and Item models with the following associations: Category hasMany Items Item belongsTo Category Label hasMany Items Item belongsTo Label So,

Re: Model with two belongsTo associations

2010-06-07 Thread vekija
It should work with Containable behavior. for example $categories = $this-Category-find('all', array('contain' = array('Item' = array('Label'; should return an array like: Category 1 Item 1 Label 1 Item 2 Label 2 Category 2 Item 3 Label 3 On Jun

Re: Model with two belongsTo associations

2010-06-07 Thread bmcelhany
Ah, I didn't realize you could nest models within a single contain...good to know! So, I gave that a shot and it works perfectly...just what I need! One additional question: I notice that for each Item there is an additional query performed to get that Item's Label information. I'm not dealing

Re: Model with two belongsTo associations

2010-06-07 Thread vekija
hmm, not sure... you could always write your own query or/and implement caching, depends on the load on you application. On Jun 7, 10:42 pm, bmcelhany bmcelh...@gmail.com wrote: Ah, I didn't realize you could nest models within a single contain...good to know! So, I gave that a shot and it