Merge branch 'main' into besnik
This commit is contained in:
commit
c1c3a75aa2
36 changed files with 1661 additions and 7 deletions
25
app/models/category_model.php
Normal file
25
app/models/category_model.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
require_once('../config/database.php');
|
||||
|
||||
/**
|
||||
* Traitement des requêtes pour les catégories
|
||||
* @author : Laura
|
||||
*/
|
||||
|
||||
class CategoryModel extends Connect{
|
||||
|
||||
public function findAllCategory(int $intLimit=0):array{
|
||||
|
||||
// Ecrire la requête
|
||||
$strRq = "SELECT category.*
|
||||
FROM category";
|
||||
|
||||
|
||||
if ($intLimit > 0){
|
||||
$strRq .= " LIMIT ".$intLimit;
|
||||
}
|
||||
|
||||
// Lancer la requête et récupérer les résultats
|
||||
return $this->_db->query($strRq)->fetchAll();
|
||||
}
|
||||
}
|
||||
25
app/models/image_model.php
Normal file
25
app/models/image_model.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
require_once('../config/database.php');
|
||||
|
||||
/**
|
||||
* Traitement de la requête pour les images
|
||||
* @author Laura
|
||||
*/
|
||||
|
||||
class ImageModel extends Connect{
|
||||
|
||||
public function findAllImage(int $intLimit=0):array{
|
||||
|
||||
// Ecrire la requête
|
||||
$strRq = "SELECT image.*
|
||||
FROM image";
|
||||
|
||||
|
||||
if ($intLimit > 0){
|
||||
$strRq .= " LIMIT ".$intLimit;
|
||||
}
|
||||
|
||||
// Lancer la requête et récupérer les résultats
|
||||
return $this->_db->query($strRq)->fetchAll();
|
||||
}
|
||||
}
|
||||
76
app/models/project_model.php
Normal file
76
app/models/project_model.php
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
require_once('../config/database.php');
|
||||
|
||||
/**
|
||||
* Traitement des requêtes pour les projets
|
||||
* @author : Laura
|
||||
*/
|
||||
|
||||
class ProjectModel extends Connect{
|
||||
|
||||
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
|
||||
$strRq = "SELECT project.*,
|
||||
CONCAT(user_firstname, ' ', user_name) AS 'project_creatorname',
|
||||
user_image
|
||||
FROM project
|
||||
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." user_id = ".$intAuthor;
|
||||
$strWhere = " AND ";
|
||||
}
|
||||
|
||||
// Recherche par catégorie
|
||||
if ($intCategory > 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;
|
||||
}
|
||||
|
||||
// Lancer la requête et récupérer les résultats
|
||||
var_dump($strRq);
|
||||
return $this->_db->query($strRq)->fetchAll();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue