= CAST(DATE_FORMAT(NOW(), '%Y-%m-%d %H:00:00') AS DATETIME) AND BR.RecordDateTime < CAST(DATE_FORMAT(NOW(), '%Y-%m-%d %H:00:00') AS DATETIME) + INTERVAL 1 HOUR AND BR.PlayerID = P.PlayerID GROUP BY BR.PlayerID "; if(is_highest_record_prefer_app($appID)) { $query = "SELECT BR.PlayerID As PlayerID, P.Name AS Name, MAX(BR.BestRecord) AS BestRecord".$query; $query = $query."ORDER BY max(BR.BestRecord) DESC;"; } else { $query = "SELECT BR.PlayerID As PlayerID, P.Name AS Name, MIN(BR.BestRecord) AS BestRecord".$query; $query = $query."ORDER BY min(BR.BestRecord) ASC;"; } $stmt = $db_conn->prepare($query); $stmt->bind_param('ii', $maestroID, $appID); $stmt->execute(); $stmt->bind_result($playerID, $name, $bestRecord); $bestRecordArray = array(); while($stmt->fetch()) { $best_record['PlayerID'] = $playerID; $best_record['Name'] = $name; $best_record['BestRecord'] = $bestRecord; array_push($bestRecordArray, $best_record); } return $bestRecordArray; } function get_ranking_day($maestroID, $appID) { global $db_conn; $query = " FROM best_record BR, player P WHERE BR.MaestroID = ? AND BR.AppID = ? AND BR.RecordDateTime >= CURDATE() AND BR.RecordDateTime < CURDATE() + INTERVAL 1 DAY AND BR.PlayerID = P.PlayerID GROUP BY BR.PlayerID "; if(is_highest_record_prefer_app($appID)) { $query = "SELECT BR.PlayerID As PlayerID, P.Name AS Name, MAX(BR.BestRecord) AS BestRecord".$query; $query = $query."ORDER BY max(BR.BestRecord) DESC;"; } else { $query = "SELECT BR.PlayerID As PlayerID, P.Name AS Name, MIN(BR.BestRecord) AS BestRecord".$query; $query = $query."ORDER BY min(BR.BestRecord) ASC;"; } $stmt = $db_conn->prepare($query); $stmt->bind_param('ii', $maestroID, $appID); $stmt->execute(); $stmt->bind_result($playerID, $name, $bestRecord); $bestRecordArray = array(); while($stmt->fetch()) { $best_record['PlayerID'] = $playerID; $best_record['Name'] = $name; $best_record['BestRecord'] = $bestRecord; array_push($bestRecordArray, $best_record); } return $bestRecordArray; } function get_ranking_month($maestroID, $appID) { global $db_conn; $query = " FROM best_record BR, player P WHERE BR.MaestroID = ? AND BR.AppID = ? AND BR.RecordDateTime >= CAST(DATE_FORMAT(CURDATE(), '%Y-%m-01') AS DATE) AND BR.RecordDateTime < CAST(DATE_FORMAT(CURDATE(), '%Y-%m-01') AS DATE) + INTERVAL 1 MONTH AND BR.PlayerID = P.PlayerID GROUP BY BR.PlayerID "; if(is_highest_record_prefer_app($appID)) { $query = "SELECT BR.PlayerID As PlayerID, P.Name AS Name, MAX(BR.BestRecord) AS BestRecord".$query; $query = $query."ORDER BY max(BR.BestRecord) DESC;"; } else { $query = "SELECT BR.PlayerID As PlayerID, P.Name AS Name, MIN(BR.BestRecord) AS BestRecord".$query; $query = $query."ORDER BY min(BR.BestRecord) ASC;"; } $stmt = $db_conn->prepare($query); $stmt->bind_param('ii', $maestroID, $appID); $stmt->execute(); $stmt->bind_result($playerID, $name, $bestRecord); $bestRecordArray = array(); while($stmt->fetch()) { $best_record['PlayerID'] = $playerID; $best_record['Name'] = $name; $best_record['BestRecord'] = $bestRecord; array_push($bestRecordArray, $best_record); } return $bestRecordArray; } ?>