I am having a hell of a time getting my association to work here. every time I run the view action on the Events controller, and use var_dump, I just get back the event info, and no company info, it's like its ignoring my association all together, and whats even more annoying is there is no error messages.
the Events table has a field called Company_ID, and the Companies table has an ID field. (yes upper case Company_ID, and ID).
class Event extends AppModel{
public $name = "Events";
// public $belongsTo = 'Company';
public $belongsTo = array('Company'=>array(
'className' => 'Company',
'foreignKey'=>'Company_ID'
));
//public $hasOne = 'Company';
/*public $hasOne = array('Company'=>array(
'className' => 'Company',
'foreignKey'=>'Company_ID'
));*/
}
App::uses("AppModel", "Model");
class Company extends AppModel{
public $name = "Company";
}
The calling controller.
public function view() {
$id = $this->request->params['id'];
$this->set(
'event',
$this->Event->find(
'first',
array('conditions' => array('Event.id' => $id))
)
);
}