From a3428d445847fbb51fffe1980ac46359271a8a9f Mon Sep 17 00:00:00 2001 From: Leander Date: Wed, 26 Apr 2017 10:24:54 +0200 Subject: [PATCH] fixed coalesce --- highscores.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/highscores.php b/highscores.php index 84a874c..a04b806 100644 --- a/highscores.php +++ b/highscores.php @@ -27,14 +27,9 @@ if($uid == '') { foreach($categories as $category) { $cid = $category['ID']; $cat = $category['name']; - $score = $db->query('SELECT COALESCE("score", -1) as "score" - FROM "Highscores" WHERE "Users_ID" = $1 AND "Categories_ID" = $2', + $score = $db->query('SELECT "score" FROM "Highscores" WHERE "Users_ID" = $1 AND "Categories_ID" = $2', array($uid, $cid))['data'][0]['score']; - /*if($score == null) { - $score = 0; - $db->query('UPDATE "Highscores" SET "score" = $1 WHERE "Users_ID" = $2 AND "Categories_ID" = $3', - array($score, $uid, $cid)); - }*/ + $score = ($score == null) ? -1 : $score; $place = $db->query( 'SELECT COUNT (*) FROM "Highscores" WHERE "Categories_ID" = $1 AND "score" > $2',