From d79b9f8f23f7ea340f8d16655507864a1cafa546 Mon Sep 17 00:00:00 2001 From: Leander Date: Fri, 31 Mar 2017 13:03:01 +0200 Subject: [PATCH] T1703311302 --- register.php | 3 ++- start.php | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/register.php b/register.php index 4a47c33..6cfe9b0 100644 --- a/register.php +++ b/register.php @@ -18,7 +18,8 @@ $error = 11101; } else { $database->query('INSERT INTO "Users" ("name", "ID") VALUES ($1, $2);', array($name, $uid)); - if(preg_match('/violates unique constraint "Users_name"/', pg_last_error()) == 1) { + print pg_last_error(); + if(preg_match('/violates unique constraint "Users_name_unique"/', pg_last_error()) == 1) { $error = 11102; } else { $data = array('uid' => $uid, 'name' => $name); diff --git a/start.php b/start.php index ed9a61c..e91bf69 100644 --- a/start.php +++ b/start.php @@ -17,10 +17,17 @@ $questions_count = $database->query('SELECT COUNT(*) FROM "Questions"')['data'][0]['count']; if($length == 0) { $error = 12101; - } - if($length > $questions_count) { + } else if($length > $questions_count) { $error = 12102; $values = array($questions_count); + } else { + /* + * if game for user exists then delete + * create new game for user + */ + if($database->query('SELECT EXISTS (SELECT 1 fROM "Games" WHERE "ID" = $1)', array($uid)) == 't') { + + } } $response = Database::create_response($data, $error, $values); print $response;