From aaf36302ac8146b497f7c397c2529cea51f3db07 Mon Sep 17 00:00:00 2001 From: "laura.chevillet" Date: Mon, 19 Jan 2026 15:46:30 +0100 Subject: [PATCH] =?UTF-8?q?maj=20models,=20entit=C3=A9=20et=20page=20reche?= =?UTF-8?q?rche,=20d=C3=A9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/project_controller.php | 12 +++--- app/models/category_model.php | 8 ++-- app/models/image_model.php | 2 +- app/models/project_model.php | 54 +++++++++++++++++++++++++- 4 files changed, 64 insertions(+), 12 deletions(-) diff --git a/app/controllers/project_controller.php b/app/controllers/project_controller.php index 497401b..3bb4a79 100644 --- a/app/controllers/project_controller.php +++ b/app/controllers/project_controller.php @@ -51,11 +51,10 @@ $strEndDate = $_GET['enddate']??''; $intCategory = $_GET['category']??0; - // Récupération des Projects + // Récupération des projetc $objProjectModel = new ProjectModel; - - // Depuis PHP 8 - accès direct aux paramètres - $arrProject = $objProjectModel->findAll(); + $arrProject = $objProjectModel->findAll(intAuthor:$intAuthor, intPeriod:$intPeriod, strDate:$strDate, + strKeywords:$strKeywords, strStartDate:$strStartDate, strEndDate:$strEndDate, intCategory:$intCategory); // Initialisation d'un tableau => objets $arrProjectToDisplay = array(); @@ -63,10 +62,11 @@ foreach($arrProject as $arrDetProject){ $objProject = new Project; $objProject->hydrate($arrDetProject); - $arrProjectToDisplay[] = $objProject; } - + + var_dump($arrProjectToDisplay); + // Récupération des utilisateurs require_once("../app/models/user_model.php"); $objUserModel = new UserModel; diff --git a/app/models/category_model.php b/app/models/category_model.php index aa13516..4aa3e6c 100644 --- a/app/models/category_model.php +++ b/app/models/category_model.php @@ -1,10 +1,10 @@ 0){ + $strRq .= $strWhere." project_creatorname = ".$intAuthor; + $strWhere = " AND "; + } + + // Recherche par catégorie + if ($intAuthor > 0){ + $strRq .= $strWhere." project_category = ".$intCategory; + $strWhere = " AND "; + } + + // Recherche par dates + if ($intPeriod == 0){ + // Par date exacte + if ($strDate != ''){ + $strRq .= $strWhere." project_creation_date = '".$strDate."'"; + } + }else{ + // Par période de dates + if ($strStartDate != '' && $strEndDate != ''){ + $strRq .= $strWhere." project_creation_date BETWEEN '".$strStartDate."' AND '".$strEndDate."'"; + }else{ + if ($strStartDate != ''){ + // A partir de + $strRq .= $strWhere." project_creation_date >= '".$strStartDate."'"; + }else if ($strEndDate != ''){ + // Avant le + $strRq .= $strWhere." project_creation_date <= '".$strEndDate."'"; + } + } + } + + $strRq .= " ORDER BY project_creation_date DESC"; + + if ($intLimit > 0){ $strRq .= " LIMIT ".$intLimit; }