Skip to content

Instantly share code, notes, and snippets.

@vexus2
Last active December 10, 2015 02:58
Show Gist options
  • Select an option

  • Save vexus2/4371916 to your computer and use it in GitHub Desktop.

Select an option

Save vexus2/4371916 to your computer and use it in GitHub Desktop.
[PHP]ユーザテーブルの登録日ごとの件数を取得
/**
* 日にち毎の会員登録ユーザ数を取得する
*/
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