From d0b7bcc83dc5d1d8133e3daf67b20c38382eb50b Mon Sep 17 00:00:00 2001 From: Anna BOUDOUL Date: Fri, 23 Dec 2022 21:12:49 +0100 Subject: [PATCH] test --- config/config.php | 4 ++-- controller/VisitorCtrl.php | 3 +-- dal/TaskGateway.php | 14 ++++++++++++++ model/TaskModel.php | 5 +++++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/config/config.php b/config/config.php index 4ab0587..7f5428a 100644 --- a/config/config.php +++ b/config/config.php @@ -3,8 +3,8 @@ $rep=__DIR__.'/../'; - $con = new Connection('mysql:host=localhost;dbname=phpproject', 'nifranco', 'achanger'); - //$con = new Connection('mysql:host=localhost;dbname=dbanboudoul', 'anboudoul', 'mdpMYSQL'); + //$con = new Connection('mysql:host=localhost;dbname=phpproject', 'nifranco', 'achanger'); + $con = new Connection('mysql:host=localhost;dbname=dbanboudoul', 'anboudoul', 'mdpMYSQL'); $TMessage = array(); diff --git a/controller/VisitorCtrl.php b/controller/VisitorCtrl.php index 93cca68..b7f3870 100644 --- a/controller/VisitorCtrl.php +++ b/controller/VisitorCtrl.php @@ -95,7 +95,6 @@ class VisitorCtrl } function loadHome(){ $public_lists = $this->taskModel->loadPublicLists(); - # le if suivant est nécéssaire dans le cas ou l'action # connection a été appeller. Dans ce cas, loadHome doit # prendre en compte le user qui vient d'être ajouter a @@ -180,7 +179,7 @@ class VisitorCtrl function isDone(){ $this->taskModel->modifTask($_POST['idT'],'isDone',true); - if($_POST['isPriv']) + if(!empty($_POST['isPriv'])) header("Location:index.php?action=voirListePriv"); else $this->loadHome(); diff --git a/dal/TaskGateway.php b/dal/TaskGateway.php index 6e3e8c3..19fc6db 100644 --- a/dal/TaskGateway.php +++ b/dal/TaskGateway.php @@ -120,6 +120,20 @@ class TaskGateway ':user'=> array($l->get_owner(),PDO::PARAM_STR))); } + public function count($list){ + $query='SELECT COUNT(*) from Tache where idList = :idList'; + + $this->con->executeQuery($query, array( + ':idList' => array($list->get_id(),PDO::PARAM_INT) + )); + + $result = $this->con->getResults(); + foreach($result as $row){ + $taille = $row[0]; + } + return $taille; + } + public function findUserList($user){ # pas réussit a faire une jointure optimale donc # decomposé en plusieurs foncitons: diff --git a/model/TaskModel.php b/model/TaskModel.php index 748a3c5..bc96bec 100644 --- a/model/TaskModel.php +++ b/model/TaskModel.php @@ -53,6 +53,11 @@ class TaskModel { $this->gtw->update('list',$id,$element,$valeur); } + + public function size($list){ + $taille = $this->gtw->count($list); + return $taille; + } public function supList($id) {