I have the following Models with the following relations between them (I just posted the relevant information about them).
Persona.php
public $hasMany = array(
'PersonaHasLdaphost' => array(
'className' => 'PersonaHasLdaphost',
'foreignKey' => 'persona_id'
)
);
Ldaphost.php
public $hasMany = array(
'PersonaHasLdaphost' => array(
'className' => 'PersonaHasLdaphost',
'foreignKey' => '__ldaphosts_id',
'dependent' => false
)
);
PersonaHasLdaphost.php
public $belongsTo = array(
'Persona' => array(
'className' => 'Persona',
'foreignKey' => 'persona_id',
),
'Ldaphost' => array(
'className' => 'Ldaphost',
'foreignKey' => '__ldaphosts_id',
)
);
I have other models, even Persona itself, with this kind of relation working just fine.
But with those ones, when I query the database with a find:
$this->Persona->Behaviors->load('Containable');
$options = array('conditions' => array('Persona.' . $this->Persona->primaryKey => $id),
'contain' => array(
'Personaacceso',
'Personainterna',
'PersonaHasLdaphost' => array('Ldaphost')),
'recursive'=>1);
$persona = $this->Persona->find('first', $options);
I get this weird ouput:
["PersonaHasLdaphost"]=> array(2) {
[0]=> array(4) {
["id"]=> string(3) "154"
["persona_id"]=> string(3) "315"
["Ldaphost"]=> array(0) {}
["PersonaHasLdaphost"]=> array(1) {
[0]=> array(1) {
["__ldaphosts_id"]=> string(2) "41"
}
}
}
[1]=> array(4) {
["id"]=> string(3) "174"
["persona_id"]=> string(3) "315"
["Ldaphost"]=> array(0) {}
["PersonaHasLdaphost"]=> array(1) {
[0]=> array(1) {
["__ldaphosts_id"]=> string(3) "120"
}
}
}
}
When it should be something like:
["PersonaHasLdaphost"]=> array(2) {
[0]=> array(4) {
["id"]=> string(3) "154"
["persona_id"]=> string(3) "315"
["__ldaphosts_id"]=> string(2) "41"
["Ldaphost"]=> array(0) {}
}
...
With data inside "Ldaphost" of course, cause there is an entry in the ldaphost table for those ids.
So can anyone give me a hint why this is happening? I can't see why this one is throwing different results than the others.