0

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

2 Answers 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

Sign up to request clarification or add additional context in comments.

Comments

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);

By using this you dont have to worry about nested arrays

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.