2012-06-30 30 views
-3

這裏的樣本是我的查詢:Kohana的ORM 3.2 - 特有的價值觀

$comment = ORM::factory('comment') 
        ->where('status', '=', 1) 
        ->find_all(); 

場= user_id

如何選擇在user_id只有每一個評論?

以下:

$comment = ORM::factory('comment') 
        ->distinct('user_id') 
        ->where('status', '=', 1) 
        ->find_all(); 

顯示一切都在數據庫!

+0

你想做什麼? 1.顯示每個user_id的最新評論。 2.爲單個user_id選擇特定註釋。 3.想知道如何將參數傳遞到模型中以選擇特定的記錄。 – MrP

回答

0

你的代碼應該更喜歡這個..

$comment = ORM::factory('comment') 
        ->where('status', '=', 1) 
        ->group_by('user_id') 
        ->find_all(); 

檢查documentation以獲得更多信息。