From 1dd827f2636272e2977f47a74b783770b3a385c2 Mon Sep 17 00:00:00 2001 From: Thomas Chazot Date: Fri, 23 Dec 2022 17:48:22 +0100 Subject: [PATCH] qzdqs --- Vues/modifyTask.php | 4 ++-- controllers/VisitorController.php | 5 +++-- gateway/TacheGateway.php | 23 +++++++++++------------ modeles/MdlTache.php | 8 +++++++- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/Vues/modifyTask.php b/Vues/modifyTask.php index 7886a81..a78d16e 100644 --- a/Vues/modifyTask.php +++ b/Vues/modifyTask.php @@ -12,12 +12,12 @@
-

Ajouter une tâche

+

Modify a task

- +
diff --git a/controllers/VisitorController.php b/controllers/VisitorController.php index 320a326..561a23b 100644 --- a/controllers/VisitorController.php +++ b/controllers/VisitorController.php @@ -42,8 +42,9 @@ class VisitorController { require($rep.$vues['addTask']); break; case "accessModifyTask": - $dataView=[$_POST['list']]; - $dataView[]=$_POST['task']; + $mdlTache= new MdlTache(); + $tache=$mdlTache->findById($_POST['task']); + $dataView=$tache; require($rep.$vues['modifyTask']); break; diff --git a/gateway/TacheGateway.php b/gateway/TacheGateway.php index bf67f0d..db98c00 100644 --- a/gateway/TacheGateway.php +++ b/gateway/TacheGateway.php @@ -43,20 +43,19 @@ class TacheGateway return $results[0]['oldId']; } -/* - public function findByName(string $name): array{ - if (!empty($name)){ - $query = "SELECT * FROM Tache WHERE name=:name"; - $this->con->executeQuery($query, array(':name' => array($name, PDO::PARAM_STR))); - - $results=$con->getResults(); - foreach ($results as $row ) { - $tabTaches[]=new Tache($row['id'], $row['name'], $row['content']); - } - return $tabTaches; + + public function findById(int $id): ?Tache{ + $tache=null; + $query = "SELECT * FROM Tache WHERE id=:id"; + $this->con->executeQuery($query, array(':id' => array($id, PDO::PARAM_STR))); + + $results=$con->getResults(); + foreach ($results as $row ) { + $tache=new Tache($row['id'], $row['name'], $row['content']); } + return $tache; + } -*/ } ?> \ No newline at end of file diff --git a/modeles/MdlTache.php b/modeles/MdlTache.php index 2513e57..7240712 100644 --- a/modeles/MdlTache.php +++ b/modeles/MdlTache.php @@ -27,12 +27,18 @@ class MdlTache{ } public function update(Tache $tache, string $name, string $content, bool $completed){ - $gate=new ListeGateway($this->con); + $gate=new TacheGateway($this->con); $tache->setName($name); $tache->setContent($content); $tache->setCompleted($completed); $gate->update($tache); } + + public function findById(int $id){ + $gate=new TacheGateway($this->con); + return $gate->findById($id); + + } }