Fix: history_record.php
This commit is contained in:
@@ -24,19 +24,31 @@ $db_conn->close();
|
|||||||
function get_history_record($maestro_id, $app_id, $player_id, $date) {
|
function get_history_record($maestro_id, $app_id, $player_id, $date) {
|
||||||
global $db_conn;
|
global $db_conn;
|
||||||
|
|
||||||
$query = "
|
$query_header = "SELECT Date(HR.RecordDateTime), HR.HighScore, HR.AppName
|
||||||
|
FROM (
|
||||||
|
";
|
||||||
|
$subquery_body = "
|
||||||
FROM best_record BR
|
FROM best_record BR
|
||||||
INNER JOIN app AS AA
|
INNER JOIN app AS AA
|
||||||
ON BR.MaestroID = ? AND BR.PlayerID = ? AND DATE(BR.RecordDateTime) <= ? AND BR.AppID = ? AND BR.AppID = AA.AppID
|
ON BR.MaestroID = ? AND BR.PlayerID = ? AND DATE(BR.RecordDateTime) <= ? AND BR.AppID = ? AND BR.AppID = AA.AppID
|
||||||
GROUP BY DATE(BR.RecordDateTime)
|
GROUP BY DATE(BR.RecordDateTime)
|
||||||
ORDER BY BR.RecordDateTime DESC
|
";
|
||||||
|
$query_tail = "
|
||||||
|
) AS HR
|
||||||
|
ORDER BY HR.RecordDateTime DESC
|
||||||
LIMIT 7
|
LIMIT 7
|
||||||
";
|
";
|
||||||
if(is_highest_record_prefer_app($app_id)) {
|
if(is_highest_record_prefer_app($app_id)) {
|
||||||
$query = "SELECT DATE(BR.RecordDateTime) AS Date, MAX(BR.BestRecord) AS HighScore, AA.AppName AS AppName".$query;
|
$query = $query_header."
|
||||||
|
SELECT DATE(BR.RecordDateTime) AS RecordDateTime, MAX(BR.BestRecord) AS HighScore, AA.AppName AS AppName
|
||||||
|
".$subquery_body
|
||||||
|
.$query_tail;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$query = "SELECT DATE(BR.RecordDateTime) AS Date, MIN(BR.BestRecord) AS HighScore, AA.AppName AS AppName".$query;
|
$query = $query_header."
|
||||||
|
SELECT DATE(BR.RecordDateTime) AS RecordDateTime, MIN(BR.BestRecord) AS HighScore, AA.AppName AS AppName
|
||||||
|
".$subquery_body
|
||||||
|
.$query_tail;
|
||||||
}
|
}
|
||||||
$stmt = $db_conn->prepare($query);
|
$stmt = $db_conn->prepare($query);
|
||||||
$stmt->bind_param('iisi', $maestro_id, $player_id, $date, $app_id);
|
$stmt->bind_param('iisi', $maestro_id, $player_id, $date, $app_id);
|
||||||
|
|||||||
Reference in New Issue
Block a user