Created
May 16, 2012 02:10
-
-
Save violetyk/2706745 to your computer and use it in GitHub Desktop.
[cakephp]Model::find()でcountとかsumとか上手くとる方法
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$this->SurveyResponse->virtualFields['count'] = 0; | |
$data = $this->SurveyResponse->find( | |
'all', | |
array( | |
'fields' => array( | |
'SurveyResponse.response_value', | |
'count(id) as "SurveyResponse__count"', | |
), | |
'conditions' => array( | |
'SurveyResponse.survey_question_id' => $survey_question_id, | |
), | |
'group' => array('SurveyResponse.response_value'), | |
'recursive' => -1, | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment