I have 2 models, Venue
and Contact
, where 1 venue has 1 contact, but 1 contact can be responsible for many venues. In my tables, venue.contactid
references the column contact.id
My models look like this:
class Contact extends AppModel {
public $useTable = 'contact';
public $belongsTo = [
'Contact'=>[
'className'=>'Venue',
'foreignKey'=>'contactid',
'conditions'=>['Contact.id = Venue.contactid']
]];
}
class Venue extends AppModel {
public $useTable = "venue";
public $hasOne = [
'Contact'=>[
'className'=>'Contact',
'foreignKey'=>'id',
'conditions'=>['Venue.contactid = Contact.id']
]];
}
The problem is that, when I retrieve the Venue, the Contact
field has everything set to null
.