From f2e574fec2193ba051b9a84eb8e9e2caa2cb80c5 Mon Sep 17 00:00:00 2001 From: "victor.soulier" Date: Sat, 18 Nov 2023 19:03:32 +0100 Subject: [PATCH] =?UTF-8?q?ADD=20:=20m=C3=A9thode=20setPseudo=20pour=20un?= =?UTF-8?q?=20joueur?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- project/src/model/gateways/JoueurGateway.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/project/src/model/gateways/JoueurGateway.php b/project/src/model/gateways/JoueurGateway.php index 5a24050..87b21a5 100644 --- a/project/src/model/gateways/JoueurGateway.php +++ b/project/src/model/gateways/JoueurGateway.php @@ -4,20 +4,20 @@ namespace model; abstract class JoueurGateway { - private $con; + protected $con; function __construct(Connection $con) { $this->con = $con; } - public function getFromPseudo($pseudo): array|bool + protected function getFromPseudo($pseudo): array|bool { $this->con->executeQuery("SELECT id, pseudo FROM Joueur WHERE pseudo = :pseudo;", [":pseudo" => [$pseudo, $this->con::PARAM_STR]]); return $this->con->getOneResult(); } - public function insertJoueur(string $pseudo): int{ + protected function insertJoueur(string $pseudo): int{ if($this->getFromPseudo($pseudo) != false){ throw new PseudoDejaPrisException(); }else{ @@ -26,4 +26,10 @@ abstract class JoueurGateway return $this->getFromPseudo($pseudo)["id"]; } } + + public function setPseudo(int $id, string $pseudo){ + $this->con->executeQuery("UPDATE Joueur SET pseudo=:pseudo WHERE id=:id", + [":pseudo" => [$pseudo, $this->con::PARAM_STR], + ":id" => [$id, $this->con::PARAM_INT]]); + } } \ No newline at end of file