(CakePHP Version 1.3.4)
I have the following association between a Contact model with Account and Test models:
class Contact extends AppModel {
var $name = 'Contact';
var $actsAs = array('Containable');
var $hasMany = array(
'Test' => array(
'className' => 'Test',
'foreignKey' => 'contact_id',
'dependent' => false
)
);
var $belongsTo = array(
'Account' => array(
'className' => 'Account',
'foreignKey' => 'account_id',
'dependent' => false
)
);
}
The following query works just fine:
$contact = $this->Contact->find('first', array(
'contain' => array(
'Account', 'Test'
),
'conditions' => array(
'Contact.id' => $contactId
)
));
But as soon as 'fields' are introduced the belongsTo association with Account breaks but the hasMany association with Test remains fine:
$contact = $this->Contact->find('first', array(
'contain' => array(
'Account', 'Test'
),
'conditions' => array(
'Contact.id' => $contactId
),
'fields' => array(
'Contact.id', 'Contact.first_name', 'Contact.last_name', 'Contact.account_id'
)
));
Does anyone else seem to have this problem?