T1703311325
This commit is contained in:
13
start.php
13
start.php
@@ -15,19 +15,22 @@
|
|||||||
$length = (($length === '0') || ($length && gettype(+$length) == 'integer')) ? +$_GET['length'] : 10;
|
$length = (($length === '0') || ($length && gettype(+$length) == 'integer')) ? +$_GET['length'] : 10;
|
||||||
$database = new Database();
|
$database = new Database();
|
||||||
$questions_count = $database->query('SELECT COUNT(*) FROM "Questions"')['data'][0]['count'];
|
$questions_count = $database->query('SELECT COUNT(*) FROM "Questions"')['data'][0]['count'];
|
||||||
|
|
||||||
|
function start_game($length) {
|
||||||
|
print 'Ich bin die Funktion.';
|
||||||
|
}
|
||||||
|
|
||||||
if($length == 0) {
|
if($length == 0) {
|
||||||
$error = 12101;
|
$error = 12101;
|
||||||
} else if($length > $questions_count) {
|
} else if($length > $questions_count) {
|
||||||
$error = 12102;
|
$error = 12102;
|
||||||
$values = array($questions_count);
|
$values = array($questions_count);
|
||||||
} else {
|
} 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') {
|
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);
|
$response = Database::create_response($data, $error, $values);
|
||||||
print $response;
|
print $response;
|
||||||
|
|||||||
Reference in New Issue
Block a user