diff --git a/WEB/Controller/EnigmeGateway.php b/WEB/Controller/EnigmeGateway.php index 2f2eb05d..a4d543a8 100644 --- a/WEB/Controller/EnigmeGateway.php +++ b/WEB/Controller/EnigmeGateway.php @@ -1,5 +1,5 @@ con->executeQuery($query, array( ':id' => array($enigme->getIdEnigme(), PDO::PARAM_STR), ':admin' => array($enigme->getAdmin(), PDO::PARAM_STR), @@ -32,7 +32,8 @@ class EnigmeGateway ':rappel' => array($enigme->getRappel(), PDO::PARAM_STR), ':solution' => array($enigme->getSolution(), PDO::PARAM_STR), ':test' => array($enigme->getTest(), PDO::PARAM_STR), - ':tempsDeResolution' => array($enigme->getTempsDeResolution(), PDO::PARAM_INT) + ':tempsDeResolution' => array($enigme->getTempsDeResolution(), PDO::PARAM_INT), + ':points' => array($enigme->getPoints(), PDO::PARAM_INT) )); } @@ -44,19 +45,24 @@ class EnigmeGateway )); } - public function findById(string $idEnigme) + public function findById(string $idEnigme) : array { $query="SELECT * FROM Enigme WHERE idEnigme =:idEnigme"; $this->con->executequery($query,array( ':idEnigme' => array($idEnigme,PDO::PARAM_STR) )); $results=$this->con->getResults(); - $tabEnigme=array(); - foreach ($results as $row) - { - $tabEnigme[]= new Enigme(row['id'],row['admin'],row['enonce'],row['aide'],row['rappel'],row['solution'],row['test'],row['tempsDeResolution']); - } - return $tabEnigme; + $tabEnigme=EnigmeFactory::create($results); + return $tabEnigme; + } + + public function findByTempsDeResolution() : array + { + $query = "SELECT * FROM Enigme ORDER BY tempsDeResolution"; + $this->con->executequery($query); + $results = $this->con->getResults(); + $tabEnigme=EnigmeFactory::create($results); + return $tabEnigme; } public function showAll(): void @@ -72,6 +78,7 @@ class EnigmeGateway echo $row['rappel'] . '
'; echo $row['solution'] . '
'; echo $row['test'] . '
'; + echo $row['points'] . '
'; } } } diff --git a/WEB/Controller/PartieGateway.php b/WEB/Controller/PartieGateway.php index 7d35c6ff..afb471df 100644 --- a/WEB/Controller/PartieGateway.php +++ b/WEB/Controller/PartieGateway.php @@ -1,4 +1,6 @@ con = $con; } public function insert(Partie $partie){ + $query= "INSERT INTO Game VALUES (:idPartie)"; $this->con->executeQuery($query, array(':idPartie' => array($partie->getIdPartie(), PDO::PARAM_STR))); } diff --git a/WEB/Factory/EnigmeFactory.php b/WEB/Factory/EnigmeFactory.php new file mode 100644 index 00000000..b84fdcae --- /dev/null +++ b/WEB/Factory/EnigmeFactory.php @@ -0,0 +1,12 @@ +idEnigme=$idEnigme; $this->enonce=$enonce; $this->solution=$solution; @@ -37,6 +38,7 @@ class Enigme $this->aide=NULL; $this->rappel=NULL; $this->admin=$admin; + $this->points=$points; } public function __constructSolo(string $idEnigme, string $enonce, string $aide, string $rappel, string $solution, string $test,string $admin){ @@ -177,4 +179,12 @@ class Enigme { $this->tempsDeResolution = $tempsDeResolution; } + public function getPoints(): int + { + return $this->points; + } + public function setPoints(int $points): void + { + $this->points = $points; + } } \ No newline at end of file diff --git a/WEB/Model/Partie.php b/WEB/Model/Partie.php index 705b2b5b..d0113343 100644 --- a/WEB/Model/Partie.php +++ b/WEB/Model/Partie.php @@ -1,11 +1,12 @@ idPartie = $idPartie; $this->datePartie = getdate(); + $listeEnigme = []; } /**