Question

I am trying to retrieve one column of ids based on a parameter being passed into my function. I want to retrieve all policy ids that have the same Coverageid that is being passed in. This is what Ive tried. I believe my Operator is in the wrong place. The reason being is when I run my script all my policies return instead of the the policies with the coverage id being passed in. I have looked around on the net but can't seem to find anything that can help me besides the PHP and Cakephp Manuals.

public function findPolicyIds($coverageId = null) {
    $id = $this->Policy->find('all', array(
        'recursive' => -1, array(
        'condition' => array('Policy.coverage_id == ' => '$coverageId',
        'fields' => array('Policy.id'))));

        return $id;
}
Was it helpful?

Solution

public function findPolicyIds($coverageId = null) {
    $id = $this->Policy->find('all', array(
        'recursive' => -1, 
        'conditions' => array('Policy.coverage_id' => $coverageId),
        'fields' => array('Policy.id')
    ));

    return $id;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top