add 12NächteChallenge2021
This commit is contained in:
@@ -33,14 +33,19 @@ class record{
|
||||
}
|
||||
|
||||
public static function getTopAchievers($options=array()){
|
||||
$query = <<<SQL
|
||||
SELECT `wkParticipo_Users`.`vorname`, `wkParticipo_Users`.`name`, COUNT(*)
|
||||
FROM `achievements<=>user`
|
||||
JOIN `wkParticipo_Users`
|
||||
ON `wkParticipo_Users`.`id` = `achievements<=>user`.`userId`
|
||||
GROUP BY `wkParticipo_Users`.`id`
|
||||
ORDER BY `COUNT(*)` DESC;
|
||||
SQL;
|
||||
$from = array_key_exists('from',$options)?$options['from']:null;
|
||||
$to = array_key_exists('to',$options)?$options['to']:null;
|
||||
$query =
|
||||
"SELECT `wkParticipo_Users`.`vorname`, `wkParticipo_Users`.`name`, COUNT(*) ".
|
||||
"FROM `achievements<=>user` JOIN `wkParticipo_Users` ".
|
||||
"ON `wkParticipo_Users`.`id` = `achievements<=>user`.`userId` ".
|
||||
(
|
||||
($from!=null&&$to!=null)?
|
||||
("BETWEEN CONVERT(\"".$from."\", datetime) AND CONVERT(\"".$to."\", datetime) "):
|
||||
("")
|
||||
).
|
||||
"GROUP BY `wkParticipo_Users`.`id` ".
|
||||
"ORDER BY `COUNT(*)` DESC;";
|
||||
return dbQuery(self::$db, $query);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user