Hi guys,
I don’t know what’s happening because thing does not add up so going to ask the community for help.
I have a mortgage which has 1 primary applicant and 1 or more (many) co-applicants.
The relation in my mortgage model is:
// primary applicant connection
'primaryApplicantConnection' => array(self::HAS_ONE, 'PersonToMortgage', 'mortgage_id',
'condition' => 'is_primary=1'
),
// primary applicant info
'primaryApplicant' => array(self::HAS_ONE, 'Person', 'person_id',
'through' => 'primaryApplicantConnection'),
// co-applicant connection
'coApplicantConnection' => array(self::HAS_MANY, 'PersonToMortgage', 'mortgage_id',
'condition' => 'is_primary<>1 OR is_primary IS NULL'
),
// co-applicants' info
'coApplicants' => array(self::HAS_MANY, 'Person', 'person_id',
'through' => 'coApplicantConnection'
),
In Mortgage Controller,
$mortgage_model=$this->loadModel($id);
$primaryApplicant = $mortgage_model->primaryApplicant; // return expect result
$coApplicants = $mortgage_model->coApplicants; // the problem is here
When I want to get all the coApplicants by using $mortgage_model->coApplicants, the result also includes primary applicant.
To track the problem down, I tried this $mortgage_model->coApplicantConnection which only return co-applicant rows.
So I wonder where primary applicant coming from ? and how it ends up in $mortgage_model->coApplicants ? is it a bug ?