|
|
@ -4,25 +4,32 @@ namespace model;
|
|
|
|
|
|
|
|
|
|
|
|
class InviteGateway extends JoueurGateway
|
|
|
|
class InviteGateway extends JoueurGateway
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private $con;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function __construct(Connection $con) {
|
|
|
|
function __construct(Connection $con) {
|
|
|
|
$this->con = $con;
|
|
|
|
parent::__construct($con);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getFromIdSession($idSession): array|bool
|
|
|
|
public function getFromIdSession($idSession): array|bool
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$this->con->executeQuery("SELECT id, pseudo, idSession FROM Invite JOIN Joueur ON id=idJoueur WHERE idSession = :idSession;",
|
|
|
|
$this->con->executeQuery("SELECT idJoueur, pseudo, idSession FROM Invite JOIN Joueur ON id=idJoueur WHERE idSession = :idSession;",
|
|
|
|
[":idSession" => [$idSession, $this->con::PARAM_STR]]);
|
|
|
|
[":idSession" => [$idSession, $this->con::PARAM_STR]]);
|
|
|
|
return $this->con->getOneResult();
|
|
|
|
return $this->con->getOneResult();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getFromId($id): array|bool
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$this->con->executeQuery("SELECT idJoueur, pseudo, idSession FROM Invite JOIN Joueur ON id=idJoueur WHERE id = :id;",
|
|
|
|
|
|
|
|
[":id" => [$id, $this->con::PARAM_INT]]);
|
|
|
|
|
|
|
|
return $this->con->getOneResult();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function insertInvite(string $pseudo, string $idSession): int{
|
|
|
|
public function insertInvite(string $pseudo, string $idSession): int{
|
|
|
|
if($this->getFromIdSession($idSession) != false){
|
|
|
|
$row = $this->getFromIdSession($idSession);
|
|
|
|
throw new IdSessionDoubleException();
|
|
|
|
if($row != false){
|
|
|
|
|
|
|
|
throw new IdSessionDoubleException($row['idjoueur'], $row['idsession']);
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
$id = $this->insertJoueur($pseudo);
|
|
|
|
$id = $this->insertJoueur($pseudo);
|
|
|
|
$this->con->executeQuery("INSERT INTO Invite(id, idSession) VALUES(:id, :idSession);",
|
|
|
|
$this->con->executeQuery("INSERT INTO Invite(idJoueur, idSession) VALUES(:id, :idSession);",
|
|
|
|
[":id" => [$id, $this->con::PARAM_INT],
|
|
|
|
[":id" => [$id, $this->con::PARAM_INT],
|
|
|
|
":idSession" => [$idSession, $this->con::PARAM_STR]]);
|
|
|
|
":idSession" => [$idSession, $this->con::PARAM_STR]]);
|
|
|
|
return $id;
|
|
|
|
return $id;
|
|
|
|