php - CakePHP Containable is generating far too many queries -


i'm using containablebehavior deep associations on find in cakephp 2.4 app. however, resulting in far many sql queries - thousands on 1 page.

to simplify relations little, looks this:

post     hasmany         - sighting             hasmany                 - field                     belongsto                         - fieldtype 

now, when find() specifying these in contain statement, debugkit mysql log filled queries this, repeated on , over:

select `fieldtype`.`id`, `fieldtype`.`name` `dev_db`.`fieldtypes`  `fieldtype` `fieldtype`.`id` = 48 

basically, it's doing manual find each , every field's fieldtype, when should have data.

is there solution returning kind of deep association not duplicate queries? i've tried using the linkable behavior, however

  • that seems work one-to-one relationships (you can't use link contain data hasmany relationship)
  • you have start main model- can't contain child records, , use linkable hook models belongto.

code:

$this->paginator->settings['contain'] = array(     'user',              'sighting' => array(         'field' => array('fieldtype')     ),           ); 


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -