From 5aaf71c7665021703b9b50582144e5c98dfc5486 Mon Sep 17 00:00:00 2001 From: Noe GARNIER Date: Thu, 10 Nov 2022 09:58:42 +0100 Subject: [PATCH 1/8] Class Controller.php + JoueurGateway.php + Traitement.php + ajout de l'inscription --- WEB/Controller/Controller.php | 45 ++++++++++++++++++ WEB/Controller/JoueurGateway.php | 44 ++++++++++++++++++ WEB/Controller/Traitement.php | 12 +++++ WEB/Controller/Validation.php | 28 +++++++++++- WEB/Controller/get.php | 43 ------------------ WEB/Model/Joueur.php | 63 ++++++++++++++++++++++++++ WEB/View/src/pages/LogSign/Login.php | 15 +++--- WEB/View/src/pages/LogSign/SignUp.html | 45 ------------------ WEB/View/src/pages/LogSign/SignUp.php | 51 +++++++++++++++++++++ 9 files changed, 251 insertions(+), 95 deletions(-) create mode 100644 WEB/Controller/Controller.php create mode 100644 WEB/Controller/JoueurGateway.php create mode 100644 WEB/Controller/Traitement.php delete mode 100644 WEB/Controller/get.php delete mode 100644 WEB/View/src/pages/LogSign/SignUp.html create mode 100644 WEB/View/src/pages/LogSign/SignUp.php diff --git a/WEB/Controller/Controller.php b/WEB/Controller/Controller.php new file mode 100644 index 00000000..8f2e60b2 --- /dev/null +++ b/WEB/Controller/Controller.php @@ -0,0 +1,45 @@ +con=$con; + session_start(); + try{ + $action=$_REQUEST['action']; + switch($action) { + case NULL: + //require ('../View/src/pages/Main.html'); + header('Location: http://londres.uca.local/~nogarnier1/Scripted/WEB/View/src/pages/Main.html'); + break; + case "login": + $this->login(); + break; + } + } catch (PDOException $e) + { + //si erreur BD, pas le cas ici + $dataVueEreur[] = "Erreur inattendue!!! "; + //require(__DIR__.'/../vues/erreur.php'); // ajout du code de la vue ici + } + catch (Exception $e2) + { + $dataVueEreur[] = "Erreur inattendue!!! "; + //require ($rep.$vues['erreur']); + } + } + + private function login() { + $gateway=new JoueurGateway($this->con); + $joueur=new Joueur($_REQUEST['email'], $_REQUEST['username'], $_REQUEST['password']); + $gateway->insert($joueur); + $gateway->showAll(); + } +} \ No newline at end of file diff --git a/WEB/Controller/JoueurGateway.php b/WEB/Controller/JoueurGateway.php new file mode 100644 index 00000000..f8e8be97 --- /dev/null +++ b/WEB/Controller/JoueurGateway.php @@ -0,0 +1,44 @@ +con = $con; + } + + /** + * @param Connection $con + */ + public function setCon(Connection $con): void + { + $this->con = $con; + } + + public function insert(Joueur $joueur) : void{ + $query = "INSERT INTO Joueur VALUE (:email,:pseudo,:mdp)"; + $this->con->executeQuery($query, array( + ':email' => array($joueur->getEmail(),PDO::PARAM_STR), + ':pseudo' => array($joueur->getPseudo(),PDO::PARAM_STR), + ':mdp' => array($joueur->getMdp(),PDO::PARAM_STR))); + } + + public function showAll() : void{ + $query = "SELECT * FROM Joueur"; + $this->con->executeQuery($query, array()); + $results=$this->con->getResults(); + foreach ($results as $row) + echo $row['email'] . '
'; + echo $row['pseudo'] . '
'; + echo $row['mdp'] . '
'; + echo '
'; + + } +} \ No newline at end of file diff --git a/WEB/Controller/Traitement.php b/WEB/Controller/Traitement.php new file mode 100644 index 00000000..1e7cf661 --- /dev/null +++ b/WEB/Controller/Traitement.php @@ -0,0 +1,12 @@ + + + + + \ No newline at end of file diff --git a/WEB/Controller/Validation.php b/WEB/Controller/Validation.php index fb682eab..2fe55341 100644 --- a/WEB/Controller/Validation.php +++ b/WEB/Controller/Validation.php @@ -2,5 +2,31 @@ class Validation { + public function ValidateSet($var) :bool{ + if (isset($var)) { + return true; + } + return false; + } -} \ No newline at end of file + public function ValidateNotEmpty($var) :bool{ + if (empty($var)) { + return false; + } + return true; + } + + public function ValidateURL(string $url) :bool{ + if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$url)) { + return false; + } + return true; + } + + public function ValidateEmail(string $email) :bool{ + if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { + return false; + } + return true; + } +} diff --git a/WEB/Controller/get.php b/WEB/Controller/get.php deleted file mode 100644 index 923b93ef..00000000 --- a/WEB/Controller/get.php +++ /dev/null @@ -1,43 +0,0 @@ - - - setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } - - public function executeQuery(string $query, array $parameters = []) :bool { - $this->stmt = parent::prepare($query); - foreach ($parameters as $name => $value) { - $this->stmt->bindValue($name, $value[0], $value[1]); } - return $this->stmt->execute(); } - public function getResults(): array { - return $this->stmt->fetchall(); - } - } - $email = $_POST['email']; - $nom = $_POST['username']; - $mdp = $_POST['password']; - - $dsn = 'mysql:host=localhost;dbname=dbnogarnier1'; - $user = 'nogarnier1'; - $password = 'achanger'; - - $con=new Connection($dsn, $user, $password); - $query = "INSERT INTO Joueur VALUE (:email,:nom,:mdp)"; - $con->executeQuery($query, array( - ':email' => array($email,PDO::PARAM_STR), - ':nom' => array($nom,PDO::PARAM_STR), - ':mdp' => array($mdp,PDO::PARAM_STR))); - - $db = new PDO($dsn, $user, $password); - $query= 'SELECT * FROM Joueur'; - $stmt=$db->prepare($query); - $stmt->execute(); - $results=$stmt->fetchall(); - Foreach ($results as $row) - echo $row['email'].'
'; - ?> - - \ No newline at end of file diff --git a/WEB/Model/Joueur.php b/WEB/Model/Joueur.php index 44c2ad8c..16635cb1 100644 --- a/WEB/Model/Joueur.php +++ b/WEB/Model/Joueur.php @@ -2,5 +2,68 @@ class Joueur { + private string $email; + private string $pseudo; + private string $mdp; + + /** + * @param string $email + * @param string $pseudo + * @param string $mdp + */ + public function __construct(string $email, string $pseudo, string $mdp) + { + $this->email = $email; + $this->pseudo = $pseudo; + $this->mdp = $mdp; + } + + /** + * @return string + */ + public function getEmail(): string + { + return $this->email; + } + + /** + * @param string $email + */ + public function setEmail(string $email): void + { + $this->email = $email; + } + + /** + * @return string + */ + public function getPseudo(): string + { + return $this->pseudo; + } + + /** + * @param string $pseudo + */ + public function setPseudo(string $pseudo): void + { + $this->pseudo = $pseudo; + } + + /** + * @return string + */ + public function getMdp(): string + { + return $this->mdp; + } + + /** + * @param string $mdp + */ + public function setMdp(string $mdp): void + { + $this->mdp = $mdp; + } } \ No newline at end of file diff --git a/WEB/View/src/pages/LogSign/Login.php b/WEB/View/src/pages/LogSign/Login.php index 0f53216c..f8c053bd 100644 --- a/WEB/View/src/pages/LogSign/Login.php +++ b/WEB/View/src/pages/LogSign/Login.php @@ -9,17 +9,13 @@ Login -< +
diff --git a/WEB/View/src/pages/LogSign/SignUp.html b/WEB/View/src/pages/LogSign/SignUp.html deleted file mode 100644 index 93d1cadb..00000000 --- a/WEB/View/src/pages/LogSign/SignUp.html +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - Login - - -
- -
- - \ No newline at end of file diff --git a/WEB/View/src/pages/LogSign/SignUp.php b/WEB/View/src/pages/LogSign/SignUp.php new file mode 100644 index 00000000..beb22719 --- /dev/null +++ b/WEB/View/src/pages/LogSign/SignUp.php @@ -0,0 +1,51 @@ + + + + + + + + + + Login + + +
+ +
+ + \ No newline at end of file From 429dceb76e0b1b2f04d55e795048168c28d4d910 Mon Sep 17 00:00:00 2001 From: Johan LACHENAL Date: Thu, 10 Nov 2022 10:00:09 +0100 Subject: [PATCH 2/8] ajout des gateways partie et enigme --- WEB/Controller/EnigmeGateway.php | 30 ++++++++++++++++++++++++++++++ WEB/Controller/PartieGateway.php | 24 ++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 WEB/Controller/EnigmeGateway.php create mode 100644 WEB/Controller/PartieGateway.php diff --git a/WEB/Controller/EnigmeGateway.php b/WEB/Controller/EnigmeGateway.php new file mode 100644 index 00000000..7046f8d1 --- /dev/null +++ b/WEB/Controller/EnigmeGateway.php @@ -0,0 +1,30 @@ +con = $con; + }/* + public function insert(string $idEnigme, string $admin, string $enonce, string $aide,string $rappel,string $solution,string $test,float $tempsDeResolution){ + $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($admin, PDO::PARAM_STR) + ':aide'=> array($admin, PDO::PARAM_STR) + ':rappel'=> array($admin, PDO::PARAM_STR) + ':solution'=> array($admin, PDO::PARAM_STR) + ':test'=> array($admin, PDO::PARAM_STR) + => array($admin, PDO::PARAM_STR) + )) + } +*/ +} +?> \ No newline at end of file diff --git a/WEB/Controller/PartieGateway.php b/WEB/Controller/PartieGateway.php new file mode 100644 index 00000000..121edb6a --- /dev/null +++ b/WEB/Controller/PartieGateway.php @@ -0,0 +1,24 @@ +con = $con; + } + public function insert(string $idPartie){ + $query= "INSERT INTO Game VALUES ('$idPartie')"; + $this->con->executeQuery($query, array(':idPartie' => array($idPartie, PDO::PARAM_STR))); + } + public function delete(string $idPartie){ + $query= "DELETE FROM Game WHERE idGame = $idPartie"; + $this->con->executeQuery($query, array(':idPartie' => array($idPartie, PDO::PARAM_STR))); + } +} \ No newline at end of file From 4d7c70e16c295916312656c5a0ddfe5d3e151009 Mon Sep 17 00:00:00 2001 From: Noe GARNIER Date: Thu, 10 Nov 2022 10:01:50 +0100 Subject: [PATCH 3/8] Class Controller.php + JoueurGateway.php + Traitement.php + ajout de l'inscription --- .idea/.gitignore | 8 ++++++++ .idea/Scripted.iml | 8 ++++++++ .idea/deployment.xml | 14 ++++++++++++++ .idea/inspectionProfiles/Project_Default.xml | 7 +++++++ .idea/modules.xml | 8 ++++++++ .idea/php.xml | 6 ++++++ .idea/vcs.xml | 6 ++++++ 7 files changed, 57 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/Scripted.iml create mode 100644 .idea/deployment.xml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/php.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..73f69e09 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/Scripted.iml b/.idea/Scripted.iml new file mode 100644 index 00000000..c956989b --- /dev/null +++ b/.idea/Scripted.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/deployment.xml b/.idea/deployment.xml new file mode 100644 index 00000000..5cb703ee --- /dev/null +++ b/.idea/deployment.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 00000000..be4b2867 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..6200ce1b --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml new file mode 100644 index 00000000..97a38d70 --- /dev/null +++ b/.idea/php.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..94a25f7f --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file From 17a56c7c66c78251acd8855d83e192de47938c65 Mon Sep 17 00:00:00 2001 From: Johan LACHENAL Date: Mon, 14 Nov 2022 12:50:46 +0100 Subject: [PATCH 4/8] modifiction de la gateway enigme --- WEB/{Controller => Config}/Connection.php | 0 WEB/{Controller => Config}/Validation.php | 0 WEB/Controller/EnigmeGateway.php | 22 ++++++++++------------ 3 files changed, 10 insertions(+), 12 deletions(-) rename WEB/{Controller => Config}/Connection.php (100%) rename WEB/{Controller => Config}/Validation.php (100%) diff --git a/WEB/Controller/Connection.php b/WEB/Config/Connection.php similarity index 100% rename from WEB/Controller/Connection.php rename to WEB/Config/Connection.php diff --git a/WEB/Controller/Validation.php b/WEB/Config/Validation.php similarity index 100% rename from WEB/Controller/Validation.php rename to WEB/Config/Validation.php diff --git a/WEB/Controller/EnigmeGateway.php b/WEB/Controller/EnigmeGateway.php index 7046f8d1..2b1c8de3 100644 --- a/WEB/Controller/EnigmeGateway.php +++ b/WEB/Controller/EnigmeGateway.php @@ -11,20 +11,18 @@ class EnigmeGateway public function __construct(Connection $con) { $this->con = $con; - }/* + } public function insert(string $idEnigme, string $admin, string $enonce, string $aide,string $rappel,string $solution,string $test,float $tempsDeResolution){ - $query="INSERT INTO Enigme VALUES ('$idEnigme','$admin','$enonce','$aide','$rappel','$solution','$test','$tempsDeResolution')"; + $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($admin, PDO::PARAM_STR) - ':aide'=> array($admin, PDO::PARAM_STR) - ':rappel'=> array($admin, PDO::PARAM_STR) - ':solution'=> array($admin, PDO::PARAM_STR) - ':test'=> array($admin, PDO::PARAM_STR) - => array($admin, PDO::PARAM_STR) - )) + ':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) + )); } -*/ } ?> \ No newline at end of file From 75c470ad707f7eb9a6322ab96af0a2f9133f74ab Mon Sep 17 00:00:00 2001 From: Johan LACHENAL Date: Mon, 14 Nov 2022 13:07:43 +0100 Subject: [PATCH 5/8] changement d'enigme gateway --- Bd/bd.sql | 2 +- WEB/Controller/EnigmeGateway.php | 48 +++++++++++++++++++++++++++----- WEB/Controller/JoueurGateway.php | 5 ++-- 3 files changed, 45 insertions(+), 10 deletions(-) diff --git a/Bd/bd.sql b/Bd/bd.sql index 2db04763..2ac6dd5b 100644 --- a/Bd/bd.sql +++ b/Bd/bd.sql @@ -7,7 +7,7 @@ mdp varchar(50) CREATE TABLE Enigme( idEnigme char(5) PRIMARY KEY, admin varchar(50) REFERENCES Admin(email), -enoncé varchar(250) NOT NULL, +enonce varchar(250) NOT NULL, aide varchar(250), rappel varchar(250), solution varchar(250) NOT NULL, diff --git a/WEB/Controller/EnigmeGateway.php b/WEB/Controller/EnigmeGateway.php index 2b1c8de3..519537d5 100644 --- a/WEB/Controller/EnigmeGateway.php +++ b/WEB/Controller/EnigmeGateway.php @@ -12,17 +12,51 @@ class EnigmeGateway { $this->con = $con; } - public function insert(string $idEnigme, string $admin, string $enonce, string $aide,string $rappel,string $solution,string $test,float $tempsDeResolution){ - $query="INSERT INTO Enigme VALUES (:idEnigme,:admin,:enonce,:aide,:rappel,:solution,:test,:tempsDeResolution)"; - $this->con->executeQuery($query,array( + + public function insert(string $idEnigme, string $admin, string $enonce, string $aide, string $rappel, string $solution, string $test, float $tempsDeResolution) + { + $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) + ':aide' => array($aide, PDO::PARAM_STR), + ':rappel' => array($rappel, PDO::PARAM_STR), + ':solution' => array($solution, PDO::PARAM_STR), + ':test' => array($tempsDeResolution, PDO::PARAM_STR) + )); + } + + public function delete(string $idEnigme) + { + $query= "DELETE FROM Enigme WHERE idEnigme=:idEnigme"; + $this->con->executequery($query, array( + ':idEnigme' => array($idEnigme,PDO::PARAM_STR) )); } + + public function findById(string $idEnigme) + { + $query="SELECT * FROM Enigme WHERE idEnigme =:idEnigme"; + $this->con->executequery($query,array( + ':idEnigme' => array($idEnigme,PDO::PARAM_STR) + )); + } + + public function showAll(): void + { + $query = "SELECT * FROM Enigme"; + $this->con->executeQuery($query); + $results = $this->con->getResults(); + foreach ($results as $row) { + echo $row['idEnigme'] . '
'; + echo $row['admin'] . '
'; + echo $row['enonce'] . '
'; + echo $row['aide'] . '
'; + echo $row['rappel'] . '
'; + echo $row['solution'] . '
'; + echo $row['test'] . '
'; + } + } } ?> \ No newline at end of file diff --git a/WEB/Controller/JoueurGateway.php b/WEB/Controller/JoueurGateway.php index f8e8be97..829653d9 100644 --- a/WEB/Controller/JoueurGateway.php +++ b/WEB/Controller/JoueurGateway.php @@ -32,13 +32,14 @@ class JoueurGateway public function showAll() : void{ $query = "SELECT * FROM Joueur"; - $this->con->executeQuery($query, array()); + $this->con->executeQuery($query); $results=$this->con->getResults(); - foreach ($results as $row) + foreach ($results as $row) { echo $row['email'] . '
'; echo $row['pseudo'] . '
'; echo $row['mdp'] . '
'; echo '
'; + } } } \ No newline at end of file From 3f9f52f9b08ee8b5ebe6c606074ec71744670ac0 Mon Sep 17 00:00:00 2001 From: Johan LACHENAL Date: Mon, 14 Nov 2022 13:20:57 +0100 Subject: [PATCH 6/8] Envoi de la correction des includes et mise en place de toutes les gateways sauf DetalPartie --- WEB/Controller/EnigmeGateway.php | 2 ++ WEB/Controller/JoueurGateway.php | 20 +++++++++++++------- WEB/Controller/PartieGateway.php | 15 ++++++++++++--- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/WEB/Controller/EnigmeGateway.php b/WEB/Controller/EnigmeGateway.php index 519537d5..434371d1 100644 --- a/WEB/Controller/EnigmeGateway.php +++ b/WEB/Controller/EnigmeGateway.php @@ -1,4 +1,6 @@ con = $con; } - public function insert(Joueur $joueur) : void{ + public function insert(string $email,string $pseudo,string $mdp) : void{ $query = "INSERT INTO Joueur VALUE (:email,:pseudo,:mdp)"; $this->con->executeQuery($query, array( - ':email' => array($joueur->getEmail(),PDO::PARAM_STR), - ':pseudo' => array($joueur->getPseudo(),PDO::PARAM_STR), - ':mdp' => array($joueur->getMdp(),PDO::PARAM_STR))); + ':email' => array($email,PDO::PARAM_STR), + ':pseudo' => array($pseudo,PDO::PARAM_STR), + ':mdp' => array($mdp,PDO::PARAM_STR))); + } + + public function delete(string $email) : void{ + $query = "DELETE FROM Joueur WHERE email=:email"; + $this->con->executeQuery($query, array( + ':email' => array($email,PDO::PARAM_STR) + )); } public function showAll() : void{ @@ -38,7 +45,6 @@ class JoueurGateway echo $row['email'] . '
'; echo $row['pseudo'] . '
'; echo $row['mdp'] . '
'; - echo '
'; } } diff --git a/WEB/Controller/PartieGateway.php b/WEB/Controller/PartieGateway.php index 121edb6a..6e12e73c 100644 --- a/WEB/Controller/PartieGateway.php +++ b/WEB/Controller/PartieGateway.php @@ -1,6 +1,7 @@ con = $con; } public function insert(string $idPartie){ - $query= "INSERT INTO Game VALUES ('$idPartie')"; + $query= "INSERT INTO Game VALUES (:idPartie)"; $this->con->executeQuery($query, array(':idPartie' => array($idPartie, PDO::PARAM_STR))); } public function delete(string $idPartie){ - $query= "DELETE FROM Game WHERE idGame = $idPartie"; + $query= "DELETE FROM Game WHERE idGame = :idPartie"; $this->con->executeQuery($query, array(':idPartie' => array($idPartie, PDO::PARAM_STR))); } + public function showAll() : void{ + $query= "SELECT * FROM Partie"; + $this->con->executeQuery($query); + $results=$this->con->getResults(); + foreach ($results as $row) { + echo $row['idPartie'] . '
'; + } + } } \ No newline at end of file From a0b3830f475ab0d689119ff51ce91bab33e1c841 Mon Sep 17 00:00:00 2001 From: Johan LACHENAL Date: Mon, 14 Nov 2022 13:56:21 +0100 Subject: [PATCH 7/8] 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 From f280f2b2b8833489efbac953df59808709325019 Mon Sep 17 00:00:00 2001 From: Johan LACHENAL Date: Mon, 14 Nov 2022 14:01:56 +0100 Subject: [PATCH 8/8] Correction des types de detailPartie --- Bd/bd.sql | 12 ++++++++++-- WEB/Model/DetailPartie.php | 35 +++++++++++++---------------------- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/Bd/bd.sql b/Bd/bd.sql index 2ac6dd5b..2c961fa7 100644 --- a/Bd/bd.sql +++ b/Bd/bd.sql @@ -22,8 +22,16 @@ pseudo varchar(50), mdp varchar(50) ); -CREATE TABLE Game( -idGame char(5) NOT NULL, +CREATE TABLE Partie( +idPartie char(5) NOT NULL, +joueur varchar(50) REFERENCES Joueur(email), +enigme char(5) REFERENCES Enigme(idEnigme), +points numeric CHECK (points >0), +PRIMARY KEY(idGame, joueur, enigme) +); + +CREATE TABLE DetailPartie( +idPartie char(5) NOT NULL, joueur varchar(50) REFERENCES Joueur(email), enigme char(5) REFERENCES Enigme(idEnigme), points numeric CHECK (points >0), diff --git a/WEB/Model/DetailPartie.php b/WEB/Model/DetailPartie.php index b048fce4..b80095cd 100644 --- a/WEB/Model/DetailPartie.php +++ b/WEB/Model/DetailPartie.php @@ -6,18 +6,18 @@ class DetailPartie private string $joueur; private string $partie; private string $enigme; - private string $pointsObtenus; - private string $classement; + private int $pointsObtenus; + private int $classement; /** * @param string $idDetailPartie * @param string $joueur * @param string $partie * @param string $enigme - * @param string $pointsObtenus - * @param string $classement + * @param int $pointsObtenus + * @param int $classement */ - public function __construct(string $idDetailPartie, string $joueur, string $partie, string $enigme, string $pointsObtenus, string $classement) + public function __construct(string $idDetailPartie, string $joueur, string $partie, string $enigme, int $pointsObtenus, int $classement) { $this->idDetailPartie = $idDetailPartie; $this->joueur = $joueur; @@ -92,43 +92,34 @@ class DetailPartie } /** - * @return string + * @return int */ - public function getPointsObtenus(): string + public function getPointsObtenus(): int { return $this->pointsObtenus; } /** - * @param string $pointsObtenus + * @param int $pointsObtenus */ - public function setPointsObtenus(string $pointsObtenus): void + public function setPointsObtenus(int $pointsObtenus): void { $this->pointsObtenus = $pointsObtenus; } /** - * @return string + * @return int */ - public function getClassement(): string + public function getClassement(): int { return $this->classement; } /** - * @param string $classement + * @param int $classement */ - public function setClassement(string $classement): void + public function setClassement(int $classement): void { $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