T1703311325

This commit is contained in:
Leander
2017-03-31 13:25:36 +02:00
parent bb892df579
commit 1f9fc9e692

View File

@@ -15,19 +15,22 @@
$length = (($length === '0') || ($length && gettype(+$length) == 'integer')) ? +$_GET['length'] : 10;
$database = new Database();
$questions_count = $database->query('SELECT COUNT(*) FROM "Questions"')['data'][0]['count'];
function start_game($length) {
print 'Ich bin die Funktion.';
}
if($length == 0) {
$error = 12101;
} 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') {
$database->query('DELETE FROM "Games" WHERE "ID" = $1', array($uid));
}
$database->query('INSERT INTO "Games" ("ID") VALUES ($1)', array($uid));
$this->create_game($length);
}
$response = Database::create_response($data, $error, $values);
print $response;