Tuesday, July 17, 2012

Re: Fast alternative to "contains"?

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
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: