parent
aa39b5db37
commit
bf3ecbd32f
@ -1,158 +0,0 @@
|
||||
<?php
|
||||
namespace Entity;
|
||||
|
||||
class UserEntity {
|
||||
|
||||
private int $id;
|
||||
private string $pseudo;
|
||||
private string $password;
|
||||
private string $email;
|
||||
private string $date;
|
||||
private bool $isAdmin;
|
||||
private int $imgPrfl;
|
||||
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId(int $id): void
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getPseudo(): string
|
||||
{
|
||||
return $this->pseudo;
|
||||
}
|
||||
|
||||
public function setPseudo(string $pseudo): void
|
||||
{
|
||||
$this->pseudo = $pseudo;
|
||||
}
|
||||
|
||||
public function getPassword(): string
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
public function setPassword(string $password): void
|
||||
{
|
||||
$this->password = $password;
|
||||
}
|
||||
|
||||
public function getEmail(): string
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function setEmail(string $email): void
|
||||
{
|
||||
$this->email = $email;
|
||||
}
|
||||
|
||||
public function getDate(): string
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
public function setDate(string $date): void
|
||||
{
|
||||
$this->date = $date;
|
||||
}
|
||||
|
||||
public function isAdmin(): bool
|
||||
{
|
||||
return $this->isAdmin;
|
||||
}
|
||||
|
||||
public function setIsAdmin(bool $isAdmin): void
|
||||
{
|
||||
$this->isAdmin = $isAdmin;
|
||||
}
|
||||
|
||||
public function getImgPrfl(): int
|
||||
{
|
||||
return $this->imgPrfl;
|
||||
}
|
||||
|
||||
public function setImgPrfl(int $imgPrfl): void
|
||||
{
|
||||
$this->imgPrfl = $imgPrfl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param string $pseudo
|
||||
* @param string $password
|
||||
* @param string $email
|
||||
* @param int $imgPrfl
|
||||
* @param bool $isAdmin
|
||||
* @param string $date
|
||||
*/
|
||||
public function __construct(int $id, string $pseudo, string $password, string $email, int $imgPrfl, bool $isAdmin, string $date)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->pseudo = $pseudo;
|
||||
$this->password = $password;
|
||||
$this->email = $email;
|
||||
$this->imgPrfl = $imgPrfl;
|
||||
$this->isAdmin = $isAdmin;
|
||||
$this->date = $date;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// ============================================ En attente du Model ============================================
|
||||
/*$dsn = "pgsql:host=londres;dbname=dblebeaulato";
|
||||
$username = "lebeaulato";
|
||||
$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']);
|
||||
|
||||
|
||||
|
||||
|
||||
//UPDATE username User
|
||||
$query = 'UPDATE Users SET username=:newUsername WHERE id_user=:idUser';
|
||||
$con->executeQuery($query, array(':idUser'=>array('U003', PDO::PARAM_STR), ':newUsername'=> array('Hello', PDO::PARAM_STR)));
|
||||
$queryReponse = 'SELECT username FROM Users WHERE id_user=:idUser';
|
||||
|
||||
$con->executeQuery($queryReponse, array(':idUser'=>array('U003', PDO::PARAM_STR)));
|
||||
$result = $con->getResults();
|
||||
$u->setUsername($result[0]['username']);
|
||||
|
||||
|
||||
//UPDATE email User
|
||||
$query = 'UPDATE Users SET email=:newEmail WHERE id_user=:idUser';
|
||||
$con->executeQuery($query, array(':idUser'=>array('U003', PDO::PARAM_STR), ':newEmail'=> array('hello@gmail.com', PDO::PARAM_STR)));
|
||||
$queryReponse = 'SELECT email FROM Users WHERE id_user=:idUser';
|
||||
|
||||
$con->executeQuery($queryReponse, array(':idUser'=>array('U003', PDO::PARAM_STR)));
|
||||
$result = $con->getResults();
|
||||
$u->setEmail($result[0]['email']);
|
||||
|
||||
//UPDATE passwd User
|
||||
$query = 'UPDATE Users SET pssword=:newPassWd WHERE id_user=:idUser';
|
||||
$con->executeQuery($query, array(':idUser'=>array('U003', PDO::PARAM_STR), ':newPassWd'=> array('TestMotDePasssse', PDO::PARAM_STR)));
|
||||
|
||||
$queryReponse = 'SELECT pssword FROM Users WHERE id_user=:idUser';
|
||||
$con->executeQuery($queryReponse, array(':idUser'=>array('U003', PDO::PARAM_STR)));
|
||||
$result = $con->getResults();
|
||||
$u->setPasswd($result[0]['pssword']); /*Test*/
|
||||
|
||||
// ================================================================================================================
|
||||
|
||||
|
||||
|
||||
function hidenPassWd(string $passwd){
|
||||
if(strlen($passwd) >= 16) return str_repeat('*', 16);
|
||||
return str_repeat('*', strlen($passwd));
|
||||
}
|
||||
?>
|
Loading…
Reference in new issue