Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cakephp Find Fields

I am trying to retrieve one column per record by way of the find(). When I execute my code It returns all the fields in the table. Here is my code. What is wrong with my code? I am using Cakephp 1.3.

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

        return $id;
}
like image 373
SkillSet Avatar asked Jan 17 '26 16:01

SkillSet


1 Answers

I think you have a extra array being formed. Try this:

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

return $id;
}

Code untested.

like image 68
Sixthpoint Avatar answered Jan 20 '26 09:01

Sixthpoint



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!