con = $con; } public function insert(string $email, string $pseudo, string $motDePasse){ $query='INSERT INTO Compte VALUES (:e, :p, :m)'; $this->con->executeQuery($query, array( ':e' => array($email, PDO::PARAM_STR), ':p' => array($pseudo, PDO::PARAM_STR), ':m' => array($motDePasse, PDO::PARAM_STR) )); } public function updateEmail(string $email, string $newEmail){ $query='UPDATE Compte SET email=:new WHERE email=:e'; $this->con->executeQuery($query, array( ':e' => array($email, PDO::PARAM_STR), ':new' => array($newEmail, PDO::PARAM_STR) )); } public function updatePseudo(string $email, string $pseudo){ $query='UPDATE Compte SET pseudo=:new WHERE email=:e'; $this->con->executeQuery($query, array( ':e' => array($email, PDO::PARAM_STR), ':new' => array($pseudo, PDO::PARAM_STR) )); } public function updateMotDePasse(string $email, string $password){ $query='UPDATE Compte SET motDePasse=:new WHERE email=:e'; $this->con->executeQuery($query, array( ':e' => array($email, PDO::PARAM_STR), ':new' => array($password, PDO::PARAM_STR) )); } public function delete(string $email){ $query='DELETE FROM Compte WHERE email=:e'; $this->con->executeQuery($query, array( ':e' => array($email, PDO::PARAM_STR) )); } public function findByPseudo(string $pseudo){ $query = 'SELECT * FROM Compte WHERE pseudo=:p'; $this->con->executeQuery($query, array( ':p' => array($pseudo, PDO::PARAM_STR) )); $res=$this->con->getResults(); return new Compte($res[0]['email'],$res[0]['pseudo'],$res[0]['motDePasse']); } public function findByEmail(string $email){ $query='SELECT * FROM Compte WHERE email=:e'; $this->con->executeQuery($query, array( ':e' => array($email, PDO::PARAM_STR), )); $res=$this->con->getResults(); return new Compte($res[0]['email'],$res[0]['pseudo'],$res[0]['motDePasse']); } public function getAll(){ $query='SELECT * FROM Compte'; $this->con->executeQuery($query); $res=$this->con->getResults(); $array=[]; foreach($res as $r){ $array[]=new Compte($r['email'],$r['pseudo'],$r['motDePasse']); } return $array; } }