ADD : getfrompseudo

php
Victor SOULIER 1 year ago
parent 8002aeed16
commit f68c570426

@ -32,4 +32,20 @@ class UtilisateurConnecteGateway extends JoueurGateway {
] ]
); );
} }
public function getFromId(int $id){
$this->con->executeQuery(
"SELECT idJoueur, pseudo, email, password FROM Utilisateur JOIN Joueur ON id=idJoueur WHERE id = :id;",
[":id" => [$id, $this->con::PARAM_INT]]
);
return $this->con->getOneResult();
}
public function getFromPseudo(string $pseudo){
$this->con->executeQuery(
"SELECT idJoueur, pseudo, email, password FROM Utilisateur JOIN Joueur ON id=idJoueur WHERE pseudo = :pseudo;",
[":pseudo" => [$pseudo, $this->con::PARAM_STR]]
);
return $this->con->getOneResult();
}
} }

@ -17,19 +17,19 @@ class MdlUser extends MdlBase{
$temp->insertJoueur($username); $temp->insertJoueur($username);
return $this->gw->register($username, $password, $temp->getFromPseudo($username)["id"]); return $this->gw->register($username, $password, $temp->getFromPseudo($username)["id"]);
} }
/*
public function setPseudo(int $id, string $pseudo): User{ public function setPseudo(int $id, string $pseudo): Utilisateur{
$this->gw->setPseudo($id, $pseudo); $this->gw->setPseudo($id, $pseudo);
return $this->getFromId($id); return $this->getFromId($id);
} }
public function insertInvite(string $pseudo, string $idSession): User{ public function getFromId(int $id): Utilisateur{
$id = $this->gw->insertInvite($pseudo, $idSession); $row = $this->gw->getFromId($id);
return $this->getFromId($id); return new Utilisateur($row['idjoueur'], $row['pseudo'], $row['email'], $row['password']);
} }
public function getFromId(int $id): User{ public function getFromPseudo(string $pseudo): Utilisateur{
$row = $this->gw->getFromId($id); $row = $this->gw->getFromPseudo($pseudo);
return new Invite($row['idjoueur'], $row['pseudo'], $row['idsession']); return new Utilisateur($row['idjoueur'], $row['pseudo'], $row['email'], $row['password']);
}*/ }
} }
Loading…
Cancel
Save