From a0b3830f475ab0d689119ff51ce91bab33e1c841 Mon Sep 17 00:00:00 2001 From: Johan LACHENAL Date: Mon, 14 Nov 2022 13:56:21 +0100 Subject: [PATCH] Correction des gateways --- WEB/Controller/DetailPartieGateway.php | 52 ++++++++++++++++++++++++++ WEB/Controller/EnigmeGateway.php | 25 +++++++++---- WEB/Controller/JoueurGateway.php | 8 ++-- WEB/Controller/PartieGateway.php | 4 +- WEB/Model/DetailPartie.php | 9 +++++ 5 files changed, 84 insertions(+), 14 deletions(-) create mode 100644 WEB/Controller/DetailPartieGateway.php diff --git a/WEB/Controller/DetailPartieGateway.php b/WEB/Controller/DetailPartieGateway.php new file mode 100644 index 00000000..2e2f8102 --- /dev/null +++ b/WEB/Controller/DetailPartieGateway.php @@ -0,0 +1,52 @@ +con = $con; + } + + /** + * @param Connection $con + */ + public function setCon(Connection $con): void + { + $this->con = $con; + } + + public function insert(DetailPartie $detailPartie) + { + $query="INSERT INTO DetailPartie VALUES (:idDetailPartie,:joueur,:partie,:enigme,:pointsObtenus,:classement)"; + $this->con->executeQuery($query,array( + 'idDetailPartie' => array($detailPartie->getIdDetailPartie(),PDO::PARAM_STR), + 'joueur' => array($detailPartie->getJoueur(),PDO::PARAM_STR), + 'partie' => array($detailPartie->getPartie(),PDO::PARAM_STR), + 'enigme' => array($detailPartie->getEnigme(),PDO::PARAM_STR), + 'pointsObtenus' => array($detailPartie->getPointsObtenus(),PDO::PARAM_INT), + 'classement' => array($detailPartie->getClassement(),PDO::PARAM_INT) + )); + } + public function delete(string $partie){ + $query="DELETE * FROM DetailPartie WHERE partie=:partie"; + $this->con->executeQuery($query,array( + 'partie' => array($partie,PDO::PARAM_STR) + )); + } + public function showAll(){ + $query="SELECT * FROM DetailPartie"; + $this->con->executeQuery($query); + $results=$this->con->getResults(); + foreach($results as $row) + { + $row['idDetailPartie']; + } + } + + +} \ No newline at end of file diff --git a/WEB/Controller/EnigmeGateway.php b/WEB/Controller/EnigmeGateway.php index 434371d1..03a33c31 100644 --- a/WEB/Controller/EnigmeGateway.php +++ b/WEB/Controller/EnigmeGateway.php @@ -15,17 +15,26 @@ class EnigmeGateway $this->con = $con; } - public function insert(string $idEnigme, string $admin, string $enonce, string $aide, string $rappel, string $solution, string $test, float $tempsDeResolution) + /** + * @param Connection $con + */ + public function setCon(Connection $con): void + { + $this->con = $con; + } + + public function insert(Enigme $enigme) { $query = "INSERT INTO Enigme VALUES (:idEnigme,:admin,:enonce,:aide,:rappel,:solution,:test,:tempsDeResolution)"; $this->con->executeQuery($query, array( - ':idEnigme' => array($idEnigme, PDO::PARAM_STR), - ':admin' => array($admin, PDO::PARAM_STR), - ':enonce' => array($enonce, PDO::PARAM_STR), - ':aide' => array($aide, PDO::PARAM_STR), - ':rappel' => array($rappel, PDO::PARAM_STR), - ':solution' => array($solution, PDO::PARAM_STR), - ':test' => array($tempsDeResolution, PDO::PARAM_STR) + ':idEnigme' => array($enigme->getIdEnigme(), PDO::PARAM_STR), + ':admin' => array($enigme->getAdmin(), PDO::PARAM_STR), + ':enonce' => array($enigme->getEnonce(), PDO::PARAM_STR), + ':aide' => array($enigme->getAide(), PDO::PARAM_STR), + ':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) )); } diff --git a/WEB/Controller/JoueurGateway.php b/WEB/Controller/JoueurGateway.php index 0d6b1156..4d49a6c5 100644 --- a/WEB/Controller/JoueurGateway.php +++ b/WEB/Controller/JoueurGateway.php @@ -22,12 +22,12 @@ class JoueurGateway $this->con = $con; } - public function insert(string $email,string $pseudo,string $mdp) : void{ + public function insert(Joueur $joueur) : void{ $query = "INSERT INTO Joueur VALUE (:email,:pseudo,:mdp)"; $this->con->executeQuery($query, array( - ':email' => array($email,PDO::PARAM_STR), - ':pseudo' => array($pseudo,PDO::PARAM_STR), - ':mdp' => array($mdp,PDO::PARAM_STR))); + ':email' => array($joueur->getEmail(),PDO::PARAM_STR), + ':pseudo' => array($joueur->getPseudo(),PDO::PARAM_STR), + ':mdp' => array($joueur->getMdp(),PDO::PARAM_STR))); } public function delete(string $email) : void{ diff --git a/WEB/Controller/PartieGateway.php b/WEB/Controller/PartieGateway.php index 6e12e73c..1b0ccaf8 100644 --- a/WEB/Controller/PartieGateway.php +++ b/WEB/Controller/PartieGateway.php @@ -14,9 +14,9 @@ class PartieGateway { $this->con = $con; } - public function insert(string $idPartie){ + public function insert(Partie $partie){ $query= "INSERT INTO Game VALUES (:idPartie)"; - $this->con->executeQuery($query, array(':idPartie' => array($idPartie, PDO::PARAM_STR))); + $this->con->executeQuery($query, array(':idPartie' => array($partie->getIdPartie(), PDO::PARAM_STR))); } public function delete(string $idPartie){ $query= "DELETE FROM Game WHERE idGame = :idPartie"; diff --git a/WEB/Model/DetailPartie.php b/WEB/Model/DetailPartie.php index 9d8eb6d6..b048fce4 100644 --- a/WEB/Model/DetailPartie.php +++ b/WEB/Model/DetailPartie.php @@ -122,4 +122,13 @@ class DetailPartie { $this->classement = $classement; } + + /** + * @param string $idDetailPartie + * @param string $joueur + * @param string $partie + * @param string $enigme + * @param int $pointsObtenus + * @param int $classement + */ } \ No newline at end of file