3

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;
}
4

2 回答 2

5

我认为您正在形成一个额外的数组。尝试这个:

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

return $id;
}

未经测试的代码。

于 2013-07-26T17:44:07.717 回答
2

试试Model::field()。我想这就是你想要的。

于 2013-07-26T18:18:11.877 回答