I believe the docs have this working alongside contains already - if you
convert your habtm to hasMany through associations and use contains for the
hasMany to generate the in( id, id2 ,id3 ) conditions then you should have
it down to a single query or at most a small handful.
Thanks for pointing out that I grabbed the wrong repo - I was trying to
find it for you in a hurry from a computer I don't use often.
On Tuesday, July 17, 2012 3:40:17 PM UTC-7, Christian wrote:
>
> Also a good one to know for future, but only works for 'hasOne' or
> 'belongsTo'. Doesn't throw an error for 'hasMany' or 'HABTM', but will not
> fetch all related data sets (or did I just use it wrong?).
>
> $this->Productgroup->find('first', array('link' => array('Category',
>>
>> 'Product' => array('Productoption' => array('Color',
>>
>> 'Size',
>>
>> 'Material'
>>
>> ),
>>
>> 'Productpresentation' => array('Productpresentationtype'
>>
>> ),
>>
>>
>>> 'Vendor'
>>
>> ),
>>
>> 'Fee',
>>
>>
>>
>> ),
>>
>> 'conditions' => array('Productgroup.id' => $id
>>
>> )
>>
>> )
>>
>> );
>>
>>
> Productgroup -> Product: HABTM
> Productgroup -> Fee: HABTM
> Productgroup -> Category: HABTM
> Product -> Productoption: hasMany
> Productoption -> Color/Size/Material: belongsTo
>
> Cheers
>
> Am Dienstag, 17. Juli 2012 01:11:31 UTC+2 schrieb gremlin:
>>
>> Try this -
>>
>> https://github.com/sams/linkable
>>
>> It is a newer version of the old linkable behavior - uses relationships
>> to create joins as well as allows you to create joins on non-default keys.
>> This might be a fairly straightforward drop in replacement for containable
>> in your case. It might not, but generating logical joins is a good start
>> towards reducing the number of small queries usually generated by
>> containable.
>> Good luck.
>>
>
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php