diff --git a/uebung10/Database.php b/uebung10/Database.php index 873949e..f4ec078 100644 --- a/uebung10/Database.php +++ b/uebung10/Database.php @@ -34,14 +34,9 @@ class Database $this->connection->close(); } - public function getQuestions($n = 0) + public function getQuestions($n = 10) { - if ($n == 0) { - $sql = "SELECT * FROM questions"; - } else { - //n ist gesetzt - $sql = "SELECT * FROM questions LIMIT $n"; - } + $sql = "SELECT * FROM questions ORDER BY RAND() LIMIT $n"; $result = $this->connection->query($sql); $resultArray = []; @@ -55,20 +50,4 @@ class Database return $resultArray; } - public function getQuestion($id) - { - $result = $this->connection->query("SELECT * FROM questions WHERE id = $id LIMIT 1"); - - $resultArray = []; - - while ($line = $result->fetch_assoc()) { - array_push($resultArray, $line); - } - - $result->free(); - - return $resultArray[0]; - } - - } diff --git a/uebung10/questions-show.php b/uebung10/api.php similarity index 84% rename from uebung10/questions-show.php rename to uebung10/api.php index fabffbc..c975b3d 100644 --- a/uebung10/questions-show.php +++ b/uebung10/api.php @@ -1,6 +1,7 @@