From 7716d00a9a67e4d42983fdf3ee147fc21fe584ea Mon Sep 17 00:00:00 2001 From: "nicolas.franco" Date: Sat, 3 Dec 2022 18:48:09 +0100 Subject: [PATCH] find finit dans TaskGateway --- business/ListTask.php | 2 +- dal/TaskGateway.php | 15 +++++++++++++-- {doc-extra => doc}/README.md | 0 {doc-extra => doc}/diagrammes/diag_classes.mdj | 0 tests/test.php | 13 ++++++++++--- 5 files changed, 24 insertions(+), 6 deletions(-) rename {doc-extra => doc}/README.md (100%) rename {doc-extra => doc}/diagrammes/diag_classes.mdj (100%) diff --git a/business/ListTask.php b/business/ListTask.php index d4c6a4d..6f77310 100644 --- a/business/ListTask.php +++ b/business/ListTask.php @@ -24,4 +24,4 @@ $this->taches = $taches; } } -?> \ No newline at end of file +?> diff --git a/dal/TaskGateway.php b/dal/TaskGateway.php index acd3a19..d45fd5f 100644 --- a/dal/TaskGateway.php +++ b/dal/TaskGateway.php @@ -47,8 +47,19 @@ class TaskGateway ':id'=>array($id,PDO::PARAM_STR))); } - # comment ça marche ? - public function Find($element, $valeur){ + /*si on veut trouver une liste, juste chercher toutes les taches avec idList= id_de_la_liste*/ + public function Find($element, $valeur){ + $query='SELECT * FROM Tache WHERE '.$element.'=:'.$element; + $this->con->executeQuery($query, array( + ':'.$element =>array($valeur,PDO::PARAM_STR))); + + $results=$this->con->getResults(); + foreach($results as $row) + { + $tabTaches[]=new Task($row['id'],$row['titre'],$row['description'],$row['priorite'], + $row['idList'],$row['dateDebut'],$row['dateFin']); + } + return $tabTaches; } } ?> diff --git a/doc-extra/README.md b/doc/README.md similarity index 100% rename from doc-extra/README.md rename to doc/README.md diff --git a/doc-extra/diagrammes/diag_classes.mdj b/doc/diagrammes/diag_classes.mdj similarity index 100% rename from doc-extra/diagrammes/diag_classes.mdj rename to doc/diagrammes/diag_classes.mdj diff --git a/tests/test.php b/tests/test.php index 8281650..328dd12 100644 --- a/tests/test.php +++ b/tests/test.php @@ -3,10 +3,17 @@ require_once("../business/Task.php"); require_once("../dal/TaskGateway.php"); echo "

2do test

"; +# nouvelle tache $t = new Task(10,'testNico','laDescription','urgent','001'); -//include("../dal/Connection.php"); + +# connection include("credentials.php"); $con = new Connection('mysql:host=localhost;dbname=phpproject',$user,$pass); + +# gateway $tgt = new TaskGateway($con); -$tgt->insert($t); -?> +//$tgt->insert($t); +//$tgt->delete('10'); +$tasks=$tgt->Find('idList','001'); +foreach($tasks as $i) + echo $i->get_id().<\br>;