Tuesday, June 30, 2009

Containable behavior and dual model relationship

I'm having some trouble using Containable with the following model
relationship.


Suppose an Airplane has two EngineTypes, with the relationships
defined like this:

class Airplane extends AppModel {
$belongsTo = array(
'EngineType' => array(
'className' => 'EngineType',
'foreignKey' => 'engine_type_id',
),
'SecondEngineType' => array(
'className' => 'EngineType',
'foreignKey' => 'second_engine_type_id',
),
);
}


I can't get my Airplane model to return the associated
SecondEngineType info using Containable behavior:

$this->Airplane->find( 'all', array(
'contain' => array(
'EngineType',
'SecondEngineType',
),
);


The first EngineType shows up, but not the SecondEngineType.

When I do a normal recursive find on Airplane, I get both.

So, I'm fairly sure this is something to do with the Containable
behavior, but I can't figure it out.

Any thoughts?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: