Well, I finally got to grips with containable behavior and have
successfully been able to write my find queries to return just the
information I need.
Now I am trying to take this to the next level and put conditions in
the contain array, but I am running into problems. I have found quite
a few posts related to this in the group, but none seem to have a
consistent solution that I can get working.
Basically, I have a function like this in my Item model:
function getBigItemList( $class ) {
$arr_contain = array(
'Product' => array(
'fields'=> array('id', 'model_number', 'range_min',
'range_max'),
'EquipmentType' => array(
'fields'=>array('id','type'),
'EquipmentClass'=> array(
'fields'=>array('class','id'),
'conditions'=> array ('EquipmentClass.id = '.$class)
)
),
),
);
$arr_c = array( 'contain' => $arr_contain );
$i_list = $this->find('all', $arr_c);
return $i_list;
}
I am trying to set a condition on the EquipmentClass table which is a
few steps removed from the Item table. (Item->Product->EquipmentType-
>EquipmentClass). Instead of returning all Items of EquipmentClass.id
= $class, I get all the Items in the table but those with a different
EquipmentClass.id than $class return a blank for that value.
I could simply eliminate the extra items from the returned array, but
the query takes a long time and I would like to optimize it to return
only the Items with the right EquipmentClass.id. What is the best way
to approach this? (I would like to force a JOIN of the equipment class
table into the main query if possible)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---