From 9915ff92faa9d200c8941cdf15c3d8f1ed2d0762 Mon Sep 17 00:00:00 2001 From: Leander Date: Fri, 21 Apr 2017 09:21:01 +0200 Subject: [PATCH] T201704210920 --- allhighscores.php | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/allhighscores.php b/allhighscores.php index 3d95ba5..dac0fb0 100644 --- a/allhighscores.php +++ b/allhighscores.php @@ -24,31 +24,18 @@ if($cid == -1) { $data[] = array('place' => $place, 'name' => $name, 'score' => $score); } } else { - $overview = $db->query('SELECT u."name", COALESCE(h."score", -1) + $overview = $db->query('SELECT u."name", h."score" FROM "Users" u LEFT OUTER JOIN "Highscores" h ON u."ID" = h."Users_ID" WHERE h."Categories_ID" = $1 ORDER BY h."score" DESC LIMIT $2 OFFSET $3', array($cid, $limit, $offset))['data']; foreach($overview as $row) { $name = $row['name']; - $score = ($row['score']); + $score = $score != NULL ? ($row['score']) : -1; $place = $db->query('SELECT COUNT(*) FROM "Highscores" WHERE "score" > $1 AND "Categories_ID" = $2', array($score, $cid))['data'][0]['count'] + 1; $data[] = array('place' => $place, 'name' => $name, 'score' => $score); } - /* - $all_cat_highscores = $db->query('SELECT COUNT(*) FROM "Highscores" WHERE "Categories_ID" = $1', array($cid)) - ['data'][0]['count']; - $all_users = $db->query('SELECT "ID", "name" FROM "Users" ORDER BY "name"')['data']; - foreach($all_users as $user) { - if($db->query('SELECT EXISTS (SELECT * FROM "Highscores" WHERE "Users_ID" = $1 AND "Categories_ID" = $2)', - array($user['ID'], $cid))['data'][0]['exists'] == 'f') { - $name = $user['name']; - $score = -1; - $place = $all_cat_highscores + 1; - $data[] = array('place' => $place, 'name' => $name, 'score' => $score); - } - }*/ } $response = Database::create_response($data, $error);