ça commence doucement
hehehe c b1 de kodé
This commit is contained in:
parent
2255eafc08
commit
28f57e9835
8 changed files with 517 additions and 11 deletions
72
app/models/project_model.php
Normal file
72
app/models/project_model.php
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
require(__DIR__ . '/../../config/database.php');
|
||||
/**
|
||||
* Traitement des requêtes pour les project
|
||||
* @author : Yass
|
||||
* @version : V0.01
|
||||
*/
|
||||
class ProjectModel extends Connect{
|
||||
|
||||
public function findAll(int $intLimit=0, string $strKeywords='', int $intAuthor=0,
|
||||
int $intPeriod=0, string $strDate='', string $strStartDate='',
|
||||
string $strEndDate=''):array{
|
||||
|
||||
// Ecrire la requête
|
||||
$strRq = "SELECT project.*,
|
||||
CONCAT(user_firstname, ' ', user_name) AS 'project_creatorname'
|
||||
FROM project
|
||||
INNER JOIN users ON user_id = project_user";
|
||||
// Pour le where (un seul)
|
||||
//$boolWhere = false; // flag
|
||||
$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){
|
||||
/*if ($boolWhere){
|
||||
$strRq .= " AND ";
|
||||
}else{
|
||||
$strRq .= " WHERE ";
|
||||
}*/
|
||||
$strRq .= $strWhere." project_creator = ".$intAuthor;
|
||||
$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 != ''){
|
||||
//if ( ($strStartDate != '') && ($strEndDate != '') ){ Parethèses selon le développeur - pas de changement si que des && - Attention ||
|
||||
$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;
|
||||
}
|
||||
|
||||
// Lancer la requête et récupérer les résultats
|
||||
return $this->_db->query($strRq)->fetchAll();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue