From b4b5fb3d3e3524d7ba2826ec72e5eb12c0da11f8 Mon Sep 17 00:00:00 2001 From: "nicolas.franco" Date: Wed, 21 Dec 2022 17:28:04 +0100 Subject: [PATCH] loadPublicLists faite --- dal/TaskGateway.php | 14 +++++++++++++- model/TaskModel.php | 9 +++++++-- tests/test.php | 2 +- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/dal/TaskGateway.php b/dal/TaskGateway.php index f63b3bc..5c7f374 100644 --- a/dal/TaskGateway.php +++ b/dal/TaskGateway.php @@ -139,8 +139,20 @@ class TaskGateway $taches[]= new Task($row['id'],$row['titre'],$row['description'],$row['priorite'], $row['idList'],$row['dateDebut'],$row['dateFin'],$row['isDone']); } - $list->set_taches($taches); + if(!empty($taches)) + $list->set_taches($taches); return $list; } + + public function findPublicList(){ + $query='SELECT * from uList where user is NULL'; + $this->con->executeQuery($query); + + $results = $this->con->getResults(); + foreach($results as $row){ + $tabLists[]= new ListTask($row[0],$row[1],$row[2],$row[3]); + } + return $tabLists; + } } ?> diff --git a/model/TaskModel.php b/model/TaskModel.php index 99d53af..b3ea54b 100644 --- a/model/TaskModel.php +++ b/model/TaskModel.php @@ -60,8 +60,13 @@ class TaskModel function loadPublicLists() { - return $this->gtw->find('list','user','NULL'); // is null!! - // requete avec jointure pour optimizer requete + $lists = $this->gtw->findPublicList(); + + foreach($lists as &$row){ + $row = $this->gtw->findListTask($row); + } + return $lists; + } function loadPrivateLists($user){ diff --git a/tests/test.php b/tests/test.php index 2ed5480..ee24aee 100644 --- a/tests/test.php +++ b/tests/test.php @@ -29,7 +29,7 @@ foreach($tasks as $i) # Test LOAD PRIVATE TASKS $mt= new TaskModel($con); -$lists = $mt->loadPrivateLists('nifranco'); +$lists = $mt->loadPublicLists(); foreach($lists as $l){ echo 'List: '.$l->get_id()."
";