generated from Templates_CodeFirst/templateHtmlCss
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
2.4 KiB
65 lines
2.4 KiB
<?php
|
|
|
|
require_once('./metier/user.php');
|
|
|
|
class UserGateway
|
|
{
|
|
private $con;
|
|
|
|
public function __construct(Connection $con){
|
|
$this->con = $con;
|
|
}
|
|
|
|
public function insert(User $u): void{
|
|
$query = "INSERT INTO Utilisateur VALUES (null, :username, :password)";
|
|
$this->con->executeQuery($query, array(':username' => array($u->getUsername(), PDO::PARAM_STR), ':password' => array($u->getPassword(), PDO::PARAM_STR)));
|
|
}
|
|
|
|
public function delete(User $u): void{
|
|
$query = "DELETE FROM Utilisateur where id=:id";
|
|
$this->con->executeQuery($query, array(':id' => array($u->getId(), PDO::PARAM_INT)));
|
|
}
|
|
|
|
public function update(User $u): void{
|
|
$query = "UPDATE Utilisateur SET username=:username, password=:password WHERE id=:id";
|
|
$this->con->executeQuery($query, array(':id' => array($u->getId(), PDO::PARAM_INT), ':username' => array($u->getUsername(), PDO::PARAM_STR), ':password' => array($u->getPassword(), PDO::PARAM_STR)));
|
|
}
|
|
|
|
public function findByNamePassword(string $username, string $password): array{
|
|
$query = "SELECT * FROM Utilisateur WHERE username=:username AND password=:password";
|
|
$this->con->executeQuery($query, array(':username' => array($username, PDO::PARAM_STR), ':password' => array($password, PDO::PARAM_STR)));
|
|
$results=$this->con->getResults();
|
|
return $results;
|
|
}
|
|
|
|
public function findByName(string $username): array{
|
|
$query = "SELECT * FROM Utilisateur WHERE username=:username";
|
|
$this->con->executeQuery($query, array(':username' => array($username, PDO::PARAM_STR)));
|
|
$results=$this->con->getResults();
|
|
return $results;
|
|
}
|
|
|
|
public function getLastId(): array{
|
|
$query = "SELECT max(id) as oldId FROM Utilisateur";
|
|
$this->con->executeQuery($query, array());
|
|
$results=$this->con->getResults();
|
|
return $results;
|
|
}
|
|
|
|
/*
|
|
public function getTacheFromIdList(int $id): array{
|
|
$tabTaches=[];
|
|
$query = "SELECT * FROM Tache t where idListe=:id";
|
|
$this->con->executeQuery($query, array(':id' => array($id, PDO::PARAM_INT)));
|
|
$results=$this->con->getResults();
|
|
foreach ($results as $row) {
|
|
$tabTaches[]=new Tache($row['id'], $row['name'], $row['content'], $row['completed']);
|
|
}
|
|
return $tabTaches;
|
|
}
|
|
|
|
|
|
*/
|
|
}
|
|
|
|
?>
|