0

嗨,我想从 cakephp 的特定列中获取不同的值。

这是我尝试过的:-

 $new_data =$this->Event->findAll(null, 'DISTINCT events.source');

Event- is the name of my model.
events- is my table name in db.
Source:- is the column name from which i want to fetch values.

我不知道查询中有什么问题,谁能帮助我

4

3 回答 3

2

findAll实际上不是 cakephp 方法。你想做的是:

$this->Event->find('all', array('fields' => 'DISTINCT Event.source'));

http://book.cakephp.org/2.0/en/models/retrieving-your-data.html#find-all

于 2013-02-28T07:23:26.847 回答
1
$this->Event->find('all', array('group' => 'Event.source'));
于 2013-02-28T12:48:39.590 回答
0
$this->Event->find('all', array('group' => 'Event.source'));
于 2013-02-28T12:37:52.340 回答