That SQL does not make sense if you are to use CActiveDataProvider philosophy.
CActiveDataProvider would provide you with an array of JobApplication models, which should be stored on the rows of your job_order_candidates table. Since pc.checklist_id
belongs to another table, you should have another model that represents those entries, and on your JobApplication class you need a relation with that model. Assuming it would be called PdpaChecklist, your JobApplication would look like this:
class JobApplication extends CActiveRecord {
// your stuff
public function relations() {
return array(
'pdpaChecklist' => array(self::HAS_ONE, 'PdpaChecklist', 'job_id'),
);
}
}
That given, you can query JobApplications as you currently do and access that pc.checklist_id
like the following:
foreach ($dataProviderSl->getData() as $jobApplication) {
$jobApplication->pdpaChecklist->checklist_id;
}
Since you will be iterating through JobApplications, it is a good idea to use eager loading, preventing Yii to run a query everytime you do $jobApplication->pdpaChecklist
. To do so, include 'pdpaChecklist' to your 'with' statement.
'with'=>array('candidate', 'pdpaChecklist'),
That is probably more work than you would have imagined, but that is how Yii organizes things. When you synergizes with the phylosophy it goes mych easily and faster. Totally worth it.