PlanDetails hasMany Companies. PlanDetail table has company_id field.
This is all I need to achieve: PlanDetail.company_id = Company.id. So get all Plan Details where PlanDetail.company_id matches Company.id.
Here is the query I have been messing with in the plan_details_controller:
function pd_list_by_company() {
$this->PlanDetail->unbindModel(array('hasMany' => array('Plan')));
$comp_id = $this->PlanDetail->Company->find('all');
$result = $this->PlanDetails->find('all', array('conditions' => array
('Company.id' => 'PlanDetail.company_id')));
$company_id = $this->PlanDetail->read('company_id');
}
I cannot just get the results I need.. what am I doing wrong here?