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