Reputation: 706
How do I write the following query in cakephp format?
SELECT COUNT( ip_address ) AS num_values
FROM property_viewers
GROUP BY property_viewers.ip_address
ORDER BY property_viewers.id DESC
Upvotes: 0
Views: 201
Reputation: 774
$options['fields'] = array("ip_address");
$options['group'] = array("property_viewers.ip_address");
$options['order'] = array('property_viewers.id DESC');
$this->model->find("count",$options);
By using this you dont have to worry about nested arrays
Upvotes: 0
Reputation: 6147
$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
Upvotes: 1