public static function usersAchievementsSta output period select array

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
public static function usersAchievementsStat($output, $period) {
$select = array();
$group = array();
$order = array('date');
$where = array();
$select[] = 'achievement_id';
if ($output == 'months') {
$select[] = "DATE_FORMAT(date, '%Y-%m') dt";
$select[] = 'SUM(days1)';
$select[] = 'SUM(days3)';
$select[] = 'SUM(days10)';
$select[] = 'SUM(days90)';
$group = array('date', 'achievement_id');
} else {
$select[] = 'date dt';
$select[] = 'days1';
$select[] = 'days3';
$select[] = 'days10';
$select[] = 'days90';
if ($period)
$where[] = "date BETWEEN '".$period['from']."' AND '".$period['to']."'";
}
return self::query(self::queryBuilder(Config::$tables['spaces_users_achievements_stat'], $select, $where, '', $group, $order), true);
}