2007年

CakePHP DISTINCT の使用方法 このエントリーを含むはてなブックマーク

CakePHP Add comments

cakebaker » Using distinct and count with CakePHP

CakePHP で DISTINCT を使いたい時の方法が紹介されていました。

$this->User->find(null, "COUNT(DISTINCT User.city) AS 'count'");

find は /cake/libs/model/model_php5.php
function find($conditions = null, $fields = null, $order = null, $recursive = null)
と定義されています。
この $fields をうまく使っているということですね。

関連する投稿

Leave a Reply

Additional comments powered by BackType

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS ログイン