diff --git a/WEB/Config/Connection.php b/WEB/Config/Connection.php index da3a86e8..c60e0b9f 100644 --- a/WEB/Config/Connection.php +++ b/WEB/Config/Connection.php @@ -45,11 +45,15 @@ class Connection extends SQLite3 public function getResults(): array { - $tmp = $this->result->fetchArray(SQLITE3_ASSOC); - if ($tmp == false) { - return array(); - } else { - return $tmp; + $resultArray = array(); + $multiArray = array(); + while($resultArray != false){ + $resultArray = $this->result->fetchArray(SQLITE3_ASSOC); //read next row + array_push($multiArray, $resultArray); //insert all rows to $multiArray } + if ($multiArray == NULL) + return array(); + else + return $multiArray; } } \ No newline at end of file diff --git a/WEB/Controller/EnigmeGateway.php b/WEB/Controller/EnigmeGateway.php index bd13b6e0..9ecba86b 100644 --- a/WEB/Controller/EnigmeGateway.php +++ b/WEB/Controller/EnigmeGateway.php @@ -51,6 +51,23 @@ class EnigmeGateway )); } + public function findMultiEnigma() : array + { + $query = "SELECT * FROM Enigme + WHERE points IS NOT NULL OR points != 0"; + $this->con->executeQuery($query); + $tabEnigme=EnigmeFactory::create($this->con->getResults()); + return $tabEnigme + } + + public function findSoloEnigma(){ + $query = "SELECT * FROM Enigme + WHERE points IS NULL OR points = 0"; + $this->con->executeQuery($query); + $tabEnigme=EnigmeFactory::create($this->con->getResults()); + return $tabEnigme + } + public function findById(string $idEnigme) : array { $query="SELECT * FROM Enigme WHERE idEnigme =:idEnigme"; diff --git a/WEB/Controller/UtilisateurGateway.php b/WEB/Controller/UtilisateurGateway.php index 954bc06b..136ebc06 100644 --- a/WEB/Controller/UtilisateurGateway.php +++ b/WEB/Controller/UtilisateurGateway.php @@ -51,10 +51,13 @@ class UtilisateurGateway if ($results == null){ return new Utilisateur("null", "null", "null", false); } - $email=$results['email']; - $pseudo=$results['pseudo']; - $mdp=$results['mdp']; - $estAdmin=$results['estAdmin']; + foreach($results as $row) + { + $email = $row['email']; + $pseudo=$row['pseudo']; + $mdp = $row['mdp']; + $estAdmin = $row['estAdmin']; + } return new Utilisateur($email, $pseudo, $mdp, $estAdmin); } diff --git a/WEB/Factory/UtilisateurFactory.php b/WEB/Factory/UtilisateurFactory.php new file mode 100644 index 00000000..03c8b27f --- /dev/null +++ b/WEB/Factory/UtilisateurFactory.php @@ -0,0 +1,14 @@ +