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