main
thchazot1 2 years ago
parent c01e499aa7
commit a5b6c86abb

@ -2,9 +2,9 @@
$rep = __DIR__ . '/../'; $rep = __DIR__ . '/../';
$login="root"; $login="thchazot1";
$password="root"; $password="achanger";
$dsn="mysql:host=localhost;port=8888;dbname=bddDeQualite"; // chemin vers bd (mysql:host=londres.uca.local;dbname=dblibreton => pour l'iut) $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"; //$dsn="mysql:host=localhost;port=8888;dbname=bddDeQualite";
/* /*
$login="thchazot1"; $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))); $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"; $query = "SELECT * FROM Utilisateur WHERE username=:username";
$this->con->executeQuery($query, array(':username' => array($username, PDO::PARAM_STR))); $this->con->executeQuery($query, array(':username' => array($username, PDO::PARAM_STR)));
$results=$this->con->getResults(); $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{ public function getLastId(): array{

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

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

Loading…
Cancel
Save