Last active
December 10, 2015 02:58
-
-
Save vexus2/4371916 to your computer and use it in GitHub Desktop.
[PHP]ユーザテーブルの登録日ごとの件数を取得
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
| /** | |
| * 日にち毎の会員登録ユーザ数を取得する | |
| */ | |
| public function getRegisterCountDayByDay ( $limit = 30 ) { | |
| $params = array( | |
| 'fields' => array( | |
| 'count(1) as count', | |
| "DATE_FORMAT(created_at,'%Y-%m-%d') as regist_date" | |
| ), | |
| 'conditions' => array( 'created_at > (now() - interval ' . $limit . ' day)' ), | |
| 'order' => array( 'regist_date' => 'asc' ), | |
| 'group' => array( 'regist_date' ), | |
| ); | |
| $result = $this->find( 'all', $params ); | |
| if ( !$result ) { | |
| return $result[ 'User' ]; | |
| } | |
| return $result; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment