From aa751016454fbd2431ae1e7cd45cc19e1fb86edf Mon Sep 17 00:00:00 2001 From: "victor.soulier" Date: Sat, 18 Nov 2023 16:23:03 +0100 Subject: [PATCH] ADD ; ajout gateway invite --- project/src/model/gateways/InviteGateway.php | 31 ++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 project/src/model/gateways/InviteGateway.php diff --git a/project/src/model/gateways/InviteGateway.php b/project/src/model/gateways/InviteGateway.php new file mode 100644 index 0000000..6d0a823 --- /dev/null +++ b/project/src/model/gateways/InviteGateway.php @@ -0,0 +1,31 @@ +con = $con; + } + + public function getFromIdSession($idSession): array|bool + { + $this->con->executeQuery("SELECT id, pseudo, idSession FROM Invite JOIN Joueur ON id=idJoueur WHERE idSession = :idSession;", + [":idSession" => [$idSession, $this->con::PARAM_STR]]); + return $this->con->getOneResult(); + } + + public function insertInvite(string $pseudo, string $idSession): int{ + if($this->getFromIdSession($idSession) != false){ + throw new IdSessionDoubleException(); + }else{ + $id = $this->insertJoueur($pseudo); + $this->con->executeQuery("INSERT INTO Invite(id, idSession) VALUES(:id, :idSession);", + [":id" => [$id, $this->con::PARAM_INT], + ":idSession" => [$idSession, $this->con::PARAM_STR]]); + return $id; + } + } +} \ No newline at end of file