From 7033bb4c1fab7d08410106e91b59a5c65878ac54 Mon Sep 17 00:00:00 2001 From: "victor.soulier" Date: Fri, 17 Nov 2023 09:46:24 +0100 Subject: [PATCH] =?UTF-8?q?ADD=20:=20m=C3=A9thode=20getFromId(id)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- project/src/model/gateways/DifficulteGateway.php | 8 ++++++++ project/src/model/gateways/JeuGateway.php | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/project/src/model/gateways/DifficulteGateway.php b/project/src/model/gateways/DifficulteGateway.php index 5917df4..0725192 100644 --- a/project/src/model/gateways/DifficulteGateway.php +++ b/project/src/model/gateways/DifficulteGateway.php @@ -18,4 +18,12 @@ class DifficulteGateway } return $listDifficulte; } + + public function getFromId(int $id): Difficulte + { + $this->con->executeQuery("SELECT id, libelle FROM Difficulte WHERE id=:id;", + [':id' => [$id, $this->con::PARAM_INT]]); + $row = $this->con->getOneResult(); + return new Difficulte($row['id'], $row['libelle']); + } } \ No newline at end of file diff --git a/project/src/model/gateways/JeuGateway.php b/project/src/model/gateways/JeuGateway.php index d1c6c92..3be2b3c 100644 --- a/project/src/model/gateways/JeuGateway.php +++ b/project/src/model/gateways/JeuGateway.php @@ -2,6 +2,8 @@ namespace model; +use PDO; + class JeuGateway { private $con; @@ -18,4 +20,12 @@ class JeuGateway } return $listJeu; } + + public function getFromId(int $id): Jeu + { + $this->con->executeQuery("SELECT id, nom, nbrparties FROM Jeu WHERE id=:id;", + [':id' => [$id, $this->con::PARAM_INT]]); + $row = $this->con->getOneResult(); + return new Jeu($row['id'], $row['nom'], $row['nbrparties']); + } } \ No newline at end of file