2013-02-28 91 views
0

您好,我想從cakephp的特定列中獲取不同的值。通過蛋糕獲得從數據庫的不同價值-php

這是我曾嘗試: -

$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. 

我硝基甲苯KNW什麼是錯的查詢,任何人都可以幫我

回答

1
$this->Event->find('all', array('group' => 'Event.source')); 
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

+0

謝謝,但我得到的輸出爲[對象對象],而不是網址 – 2013-02-28 07:27:02

+0

而且還值的arent不同 – 2013-02-28 07:27:22

+0

你是什麼意思通過[object Object]?這聽起來像JavaScript。 – yourdeveloperfriend 2013-02-28 07:31:06

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