maj models, entité et page recherche, débug
This commit is contained in:
parent
c0aab723d7
commit
aaf36302ac
4 changed files with 64 additions and 12 deletions
|
|
@ -51,11 +51,10 @@
|
||||||
$strEndDate = $_GET['enddate']??'';
|
$strEndDate = $_GET['enddate']??'';
|
||||||
$intCategory = $_GET['category']??0;
|
$intCategory = $_GET['category']??0;
|
||||||
|
|
||||||
// Récupération des Projects
|
// Récupération des projetc
|
||||||
$objProjectModel = new ProjectModel;
|
$objProjectModel = new ProjectModel;
|
||||||
|
$arrProject = $objProjectModel->findAll(intAuthor:$intAuthor, intPeriod:$intPeriod, strDate:$strDate,
|
||||||
// Depuis PHP 8 - accès direct aux paramètres
|
strKeywords:$strKeywords, strStartDate:$strStartDate, strEndDate:$strEndDate, intCategory:$intCategory);
|
||||||
$arrProject = $objProjectModel->findAll();
|
|
||||||
|
|
||||||
// Initialisation d'un tableau => objets
|
// Initialisation d'un tableau => objets
|
||||||
$arrProjectToDisplay = array();
|
$arrProjectToDisplay = array();
|
||||||
|
|
@ -63,10 +62,11 @@
|
||||||
foreach($arrProject as $arrDetProject){
|
foreach($arrProject as $arrDetProject){
|
||||||
$objProject = new Project;
|
$objProject = new Project;
|
||||||
$objProject->hydrate($arrDetProject);
|
$objProject->hydrate($arrDetProject);
|
||||||
|
|
||||||
$arrProjectToDisplay[] = $objProject;
|
$arrProjectToDisplay[] = $objProject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var_dump($arrProjectToDisplay);
|
||||||
|
|
||||||
// Récupération des utilisateurs
|
// Récupération des utilisateurs
|
||||||
require_once("../app/models/user_model.php");
|
require_once("../app/models/user_model.php");
|
||||||
$objUserModel = new UserModel;
|
$objUserModel = new UserModel;
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
require_once('../config/database.php');
|
require_once('../config/database.php');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Classe d'un objet Projet
|
* Traitement des requêtes pour les catégories
|
||||||
* @author Laura
|
* @author : Laura
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class CategoryModel extends Connect{
|
class CategoryModel extends Connect{
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
require_once('../config/database.php');
|
require_once('../config/database.php');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Classe d'un objet Projet
|
* Traitement de la requête pour les images
|
||||||
* @author Laura
|
* @author Laura
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,16 @@
|
||||||
<?php
|
<?php
|
||||||
require_once('../config/database.php');
|
require_once('../config/database.php');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Traitement des requêtes pour les projets
|
||||||
|
* @author : Laura
|
||||||
|
*/
|
||||||
|
|
||||||
class ProjectModel extends Connect{
|
class ProjectModel extends Connect{
|
||||||
|
|
||||||
public function findAll(int $intLimit=0):array{
|
public function findAll(int $intLimit=0, string $strKeywords='', int $intAuthor=0,
|
||||||
|
int $intPeriod=0, string $strDate='', string $strStartDate='',
|
||||||
|
string $strEndDate='', int $intCategory=0):array{
|
||||||
|
|
||||||
// Ecrire la requête
|
// Ecrire la requête
|
||||||
$strRq = "SELECT project.*,
|
$strRq = "SELECT project.*,
|
||||||
|
|
@ -12,6 +19,51 @@
|
||||||
FROM project
|
FROM project
|
||||||
INNER JOIN users ON user_id = project_user";
|
INNER JOIN users ON user_id = project_user";
|
||||||
|
|
||||||
|
$strWhere = " WHERE ";
|
||||||
|
// Recherche par mot clé
|
||||||
|
if ($strKeywords != '') {
|
||||||
|
$strRq .= " WHERE (project_title LIKE '%".$strKeywords."%'
|
||||||
|
OR project_content LIKE '%".$strKeywords."%') ";
|
||||||
|
|
||||||
|
//$boolWhere = true;
|
||||||
|
$strWhere = " AND ";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recherche par auteur
|
||||||
|
if ($intAuthor > 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){
|
if ($intLimit > 0){
|
||||||
$strRq .= " LIMIT ".$intLimit;
|
$strRq .= " LIMIT ".$intLimit;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue