From 33aecbe7c8cf9d315d06c984ba9c1527a78ad79d Mon Sep 17 00:00:00 2001 From: Johan LACHENAL Date: Wed, 23 Nov 2022 17:24:21 +0100 Subject: [PATCH] =?UTF-8?q?Changement=20des=20PARam=20stdo=20n=C3=A9cessai?= =?UTF-8?q?re=20puisque=20les=20id=20sont=20d=C3=A9sormais=20des=20int=20m?= =?UTF-8?q?odification=20substantielle=20de=20la=20bdd=20suite=20a=20des?= =?UTF-8?q?=20reflexions=20lors=20du=20developpement=20des=20gateways?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WEB/Controller/JoueurGateway.php | 14 ++++++++++++++ WEB/Model/Partie.php | 8 ++++---- WEB/Model/bd.sql | 5 +++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/WEB/Controller/JoueurGateway.php b/WEB/Controller/JoueurGateway.php index 0f867088..3b2232d0 100644 --- a/WEB/Controller/JoueurGateway.php +++ b/WEB/Controller/JoueurGateway.php @@ -70,6 +70,20 @@ class JoueurGateway return $mdp; } + /*public function resoudreEnigme(string $idJoueur,Partie $partie){ + $query=" SELECT count(:idJoueur) FROM PasserEnMulti pm, Partie p, + WHERE p.id=pm.partie + AND pm.idJoueur = :idJoueur"; + $this->con->executeQuery($query); + $index = $this->con->getResults(); + $query =" INSERT INTO PasserEnMulti VALUES (:idJoueur,:idpartie,:idEnigme,TRUE,:tempsPartie)"; + $this->con->executeQuery($query, array( + 'idJoueur' => array($idJoueur,PDO::PARAM_STR), + 'idPartie' => array($partie->getIdPartie(),PDO::PARAM_INT), + 'idEnigme' => array($partie->getListeEnigme()[$index]->getIdEnigme,PDO::PARAM_INT), + 'tempsPartie' => array(getdate()-$partie->getDatePartie()),PDO::PARAM_STR)); + }*/ + public function showAll() : void{ $query = "SELECT * FROM Joueur"; $this->con->executeQuery($query); diff --git a/WEB/Model/Partie.php b/WEB/Model/Partie.php index 860f4cf5..f0899047 100644 --- a/WEB/Model/Partie.php +++ b/WEB/Model/Partie.php @@ -5,7 +5,7 @@ include_once "Enigme.php"; class Partie { private string $idPartie; - private $datePartie; + private DateTime $datePartie; private array $listeEnigme; /** @@ -15,7 +15,7 @@ class Partie public function __construct(string $idPartie, array $listeEnigme) { $this->idPartie = $idPartie; - $this->datePartie = getdate(); + $this->datePartie = new DateTime(); $this->$listeEnigme = $listeEnigme; } @@ -38,7 +38,7 @@ class Partie /** * @return array */ - public function getDatePartie(): array + public function getDatePartie(): dateTime { return $this->datePartie; } @@ -46,7 +46,7 @@ class Partie /** * @param array $datePartie */ - public function setDatePartie(array $datePartie): void + public function setDatePartie(dateTime $datePartie): void { $this->datePartie = $datePartie; } diff --git a/WEB/Model/bd.sql b/WEB/Model/bd.sql index f2ee3908..941df31d 100644 --- a/WEB/Model/bd.sql +++ b/WEB/Model/bd.sql @@ -48,11 +48,12 @@ indexEnigme numeric UNIQUE, PRIMARY KEY(joueur, enigme) ); -CREATE TABLE ResoudreEnMulti( +CREATE TABLE PasserEnMulti( joueur varchar(50) REFERENCES Joueur(email), enigme char(5) REFERENCES Enigme(id), partie char(5) REFERENCES Partie(id), -indexEnigme numeric UNIQUE, +passer bool NOT NULL, +points numeric NOT NULL, temps time, PRIMARY KEY(joueur, enigme, partie) );