main
thchazot1 2 years ago
parent c01e499aa7
commit a5b6c86abb

@ -2,9 +2,9 @@
$rep = __DIR__ . '/../';
$login="root";
$password="root";
$dsn="mysql:host=localhost;port=8888;dbname=bddDeQualite"; // chemin vers bd (mysql:host=londres.uca.local;dbname=dblibreton => pour l'iut)
$login="thchazot1";
$password="achanger";
$dsn="mysql:host=localhost;dbname=dbthchazot1"; // chemin vers bd (mysql:host=londres.uca.local;dbname=dblibreton => pour l'iut)
//$dsn="mysql:host=localhost;port=8888;dbname=bddDeQualite";
/*
$login="thchazot1";

@ -34,11 +34,15 @@ class UserGateway
$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 findByName(string $username): array{
public function findByName(string $username): ?User{
$usr=null;
$query = "SELECT * FROM Utilisateur WHERE username=:username";
$this->con->executeQuery($query, array(':username' => array($username, PDO::PARAM_STR)));
$results=$this->con->getResults();
return $results[0];
foreach ($results as $user){
$usr = new User($user['id'], $user['username'], $user['password']);
}
return $usr;
}
public function getLastId(): array{

@ -71,14 +71,12 @@ class MdlListe{
return $tabListe;
}
public function findByUser(string $username): array{
public function findByUser(User $user): array{
$gate=new ListeGateway($this->con);
$gateTache=new TacheGateway($this->con);
$gateUser=new UserGateway($this->con);
$id=$gateUser->findByName($username);
$id=$id['id'];
$results=$gate->findByUserId($id);
$results=$gate->findByUserId($user->getId());
$tabListe=[];
foreach ($results as $row ) {
$tabTache=[];
@ -86,7 +84,7 @@ class MdlListe{
foreach($taches as $tata){
$tabTache[]=new Tache($tata['id'], $tata['name'], $tata['content'], $tata['completed']);
}
$tabListe[]=new Liste($row['id'], $row['name'], $row['private'], $u, $tabTache);
$tabListe[]=new Liste($row['id'], $row['name'], $row['private'], $user, $tabTache);
}
return $tabListe;
}

@ -60,7 +60,7 @@ class MdlUser{
public function findByName(string $usr){
$gate=new UserGateway($this->con);
$result=$gate->findByName($usr);
return new User($result['id'], $usr, $result['password']);
return $result;
}
}

Loading…
Cancel
Save