0

如何以 cakephp 格式编写以下查询?

SELECT COUNT( ip_address ) AS num_values
FROM property_viewers
GROUP BY property_viewers.ip_address
ORDER BY property_viewers.id DESC
4

2 回答 2

1
 $this->model->find("count",array("fields"=>"ip_address",'group'=>'property_viewers.ip_address','order'=>'property_viewers.id DESC'))

http://book.cakephp.org/1.3/view/1018/find#find-count-1020

于 2012-07-06T04:57:05.190 回答
0
 $options['fields'] = array("ip_address");
 $options['group']  = array("property_viewers.ip_address"); 
 $options['order']  = array('property_viewers.id DESC');
 $this->model->find("count",$options);

通过使用它,您不必担心嵌套数组

于 2015-05-23T12:09:50.340 回答