diff --git a/src/Entity/userEntity.php b/src/Entity/userEntity.php index 872af73..d2ccf0b 100644 --- a/src/Entity/userEntity.php +++ b/src/Entity/userEntity.php @@ -121,18 +121,17 @@ } // ============================================ En attente du Model ============================================ - include("../src/Gateway/Connection.php"); - $dsn = "pgsql:host=londres;dbname=dblebeaulato"; + /*$dsn = "pgsql:host=londres;dbname=dblebeaulato"; $username = "lebeaulato"; - $password = "MaSQL:2004!"; - + $password = ""; + $con = new Connection($dsn,$username,$password); $query = 'SELECT * FROM Users WHERE id_user=:idUser'; $con->executeQuery($query, array(':idUser'=>array('U003', PDO::PARAM_STR))); $result = $con->getResults(); - $u = new User($result[0]['id_user'],$result[0]['username'], $result[0]['pssword'], '../images/imageProfil.png', $result[0]['email']); /*Test*/ + $u = new User($result[0]['id_user'],$result[0]['username'], $result[0]['pssword'], '../images/imageProfil.png', $result[0]['email']); @@ -144,7 +143,7 @@ $con->executeQuery($queryReponse, array(':idUser'=>array('U003', PDO::PARAM_STR))); $result = $con->getResults(); - $u->setUsername($result[0]['username']); /*Test*/ + $u->setUsername($result[0]['username']); //UPDATE email User @@ -154,7 +153,7 @@ $con->executeQuery($queryReponse, array(':idUser'=>array('U003', PDO::PARAM_STR))); $result = $con->getResults(); - $u->setEmail($result[0]['email']); /*Test*/ + $u->setEmail($result[0]['email']); //UPDATE passwd User $query = 'UPDATE Users SET pssword=:newPassWd WHERE id_user=:idUser'; diff --git a/src/Gateway/userGateway.php b/src/Gateway/userGateway.php index ec7b93e..6a51b7d 100644 --- a/src/Gateway/userGateway.php +++ b/src/Gateway/userGateway.php @@ -42,7 +42,7 @@ Class UserGateway{ - public function donneeUser(string $id):array{ + public function findDataUser(string $id):array{ $query = 'SELECT * FROM Users WHERE id_user=:idUser'; $con->executeQuery($query, array(':idUser'=>array($id, PDO::PARAM_STR))); $result = $con->getResults(); @@ -99,11 +99,7 @@ Class UserGateway{ } } -<<<<<<< HEAD $uG = new UserGateway(new Connection("pgsql:host=londres;dbname=dblebeaulato","lebeaulato","")); ?> -======= -?> ->>>>>>> refs/remotes/origin/reorganisation diff --git a/src/Model/userModel.php b/src/Model/userModel.php index b6ed412..db0b5f3 100644 --- a/src/Model/userModel.php +++ b/src/Model/userModel.php @@ -20,6 +20,58 @@ public function deletUser(string $id) : bool{ return $this->gateway->delete($id); } + + + // public function getFavoriteUser(string $id) : array{ + // $res = array(); + // $data = $this->gateway->getFavorite($id); + // foreach ($data as $favoris) { + // $res[] = new Quote(); + // } + // } + + public function getDataUser(string $id){ + $res = $this->gateway->findDataUser($id); + foreach($res as $sources){ + $src[] = new sourceEntity( + $sources['id_user'], + $sources['username'], + $sources['pssword'], + $sources['img'], + $sources['email'] + ); + } + return $src; + } + + + public function setUsername(string $id, string $newUsername){ + $res = $this->gateway->updateUsername($id,$newUsername); + $src[] = new sourceEntity($res['username']); + + return $src; + } + + public function setEmail(string $id, string $newEmail){ + $res = $this->gateway->updateEmail($id,$newEmail); + $src[] = new sourceEntity($res['email']); + + return $src; + } + + public function setImg(string $id, string $newImg){ + $res = $this->gateway->updateImg($id,$newImg); + $src[] = new sourceEntity($res['img']); + + return $src; + } + + public function setPassWd(string $id, string $newPassWd){ + $res = $this->gateway->updatePasswd($id,$newPassWd); + $src[] = new sourceEntity($res['pssword']); + + return $src; + } } ?>