smarty ça casse les couilles zebi
This commit is contained in:
parent
b1960b2f35
commit
aec3c845e0
469 changed files with 53465 additions and 69 deletions
0
models/.gitkeep
Normal file
0
models/.gitkeep
Normal file
47
models/category_model.php
Normal file
47
models/category_model.php
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
require_once('./config/database.php');
|
||||
|
||||
/**
|
||||
* Traitement des requêtes pour les catégories
|
||||
* @author : Laura
|
||||
*/
|
||||
|
||||
class CategoryModel extends Connect{
|
||||
|
||||
/**
|
||||
* Fonction de récupération des catégories
|
||||
* @return array
|
||||
*/
|
||||
|
||||
public function findAllCategory(int $intLimit=0):array{
|
||||
|
||||
$strRq = "SELECT category.*
|
||||
FROM category";
|
||||
|
||||
if ($intLimit > 0){
|
||||
$strRq .= " LIMIT ".$intLimit;
|
||||
}
|
||||
|
||||
return $this->_db->query($strRq)->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* fonction d'insertion d'une nouvelle catégorie dans la bdd
|
||||
* @param object $objUser L'objet utilisateur
|
||||
* @return bool Est-ce que la requête s'est bien passée (true/false)
|
||||
*/
|
||||
|
||||
public function insert(object $objCategory):bool{
|
||||
|
||||
$strRq = "INSERT INTO category (category_name, category_parent)
|
||||
VALUES (:name, :parent)";
|
||||
|
||||
$rqPrep = $this->_db->prepare($strRq);
|
||||
|
||||
$rqPrep->bindValue(":name", $objCategory->getName(), PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(":parent", $objCategory->getParent(), PDO::PARAM_STR);
|
||||
|
||||
return $rqPrep->execute();
|
||||
|
||||
}
|
||||
}
|
||||
28
models/image_model.php
Normal file
28
models/image_model.php
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
require_once('./config/database.php');
|
||||
|
||||
/**
|
||||
* Traitement de la requête pour les images
|
||||
* @author Laura
|
||||
*/
|
||||
|
||||
class ImageModel extends Connect{
|
||||
|
||||
/**
|
||||
* Fonction de récupération des images
|
||||
* @return array
|
||||
*/
|
||||
|
||||
public function findAllImage(int $intLimit=0):array{
|
||||
|
||||
$strRq = "SELECT image.*
|
||||
FROM image";
|
||||
|
||||
|
||||
if ($intLimit > 0){
|
||||
$strRq .= " LIMIT ".$intLimit;
|
||||
}
|
||||
|
||||
return $this->_db->query($strRq)->fetchAll();
|
||||
}
|
||||
}
|
||||
97
models/project_model.php
Normal file
97
models/project_model.php
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
<?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
|
||||
return $this->_db->query($strRq)->fetchAll();
|
||||
}
|
||||
|
||||
//Fonction d'insertion d'information dans la BDD (Repris de la partie BLOG vu en cours..)
|
||||
public function insert(object $objProject):bool{
|
||||
|
||||
//Construire la requête
|
||||
$strRq = "INSERT INTO project (project_title, project_description, project_thumbnail, project_content, project_status, project_creation_date)
|
||||
VALUES (:title, :description, :thumbnail, :content, :status, DATE(NOW()))";
|
||||
|
||||
// Préparer la requête
|
||||
$rqPrep = $this->_db->prepare($strRq);
|
||||
// Donne les informations
|
||||
$rqPrep->bindValue(":title", $objProject->getTitle(), PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(":description", $objProject->getDescription(), PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(":thumbnail", $objProject->getThumbnail(), PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(":content", $objProject->getContent(), PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(":status", $objProject->getStatus(), PDO::PARAM_STR);
|
||||
|
||||
//Executer la requête
|
||||
//var_dump($strRq);die;
|
||||
//return $db->exec($strRq);
|
||||
return $rqPrep->execute();
|
||||
}
|
||||
}
|
||||
84
models/user_model.php
Normal file
84
models/user_model.php
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
require_once('./config/database.php');
|
||||
|
||||
/**
|
||||
* Traitement des requêtes pour les utilisateurs
|
||||
* @author : meilleurGroup
|
||||
* @version : V0.5
|
||||
*/
|
||||
class UserModel extends Connect{
|
||||
// Attributs
|
||||
|
||||
|
||||
// Méthodes
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function findAllUsers():array{
|
||||
// Ecrire la requête
|
||||
$strRq = "SELECT user_id, user_firstname, user_name, user_image
|
||||
FROM users ";
|
||||
// Lancer la requête et récupérer les résultats
|
||||
return $this->_db->query($strRq)->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $strMail
|
||||
* @param string $strPwd
|
||||
* @return array|bool
|
||||
*/
|
||||
public function verifUser(string $strMail, string $strPwd):array|bool{
|
||||
// 2. Construire la requête
|
||||
$strRq = "SELECT user_id, user_name, user_firstname, user_password, user_image
|
||||
FROM users
|
||||
WHERE user_mail = '".$strMail."'";
|
||||
// Récupère mon utilisateur
|
||||
// Executer la requête et récupérer les résultats
|
||||
$arrUser = $this->_db->query($strRq)->fetch();
|
||||
// Vérification du mot de passe haché
|
||||
if (password_verify($strPwd, $arrUser['user_password'])){
|
||||
// Renvoi l'utilisateur
|
||||
unset($arrUser['user_password']); // on enlève le pwd
|
||||
return $arrUser;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//public function insert(string $strName, string $strFirstname, string $strMail, string $strPwd):int{
|
||||
/**
|
||||
* Fonction d'insertion d'un utilisateur en BDD
|
||||
* @param object $objUser L'objet utilisateur
|
||||
* @return bool Est-ce que la requête s'est bien passée (true/false)
|
||||
*/
|
||||
public function insert(object $objUser):bool{
|
||||
|
||||
// 2. Construire la requête
|
||||
|
||||
$strRq = "INSERT INTO users (user_name, user_firstname, user_pseudo, user_mail, user_password, user_phone, user_work, user_location, user_description)
|
||||
VALUES (:name, :firstname, :pseudo,:mail, :pwd, :phone, :work, :location,:description)";
|
||||
// Préparer la requête
|
||||
$rqPrep = $this->_db->prepare($strRq);
|
||||
// Donne les informations
|
||||
$rqPrep->bindValue(":name", $objUser->getName(), PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(":firstname", $objUser->getFirstname(), PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(":pseudo", $objUser->getPseudo(), PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(":mail", $objUser->getMail(), PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(":pwd", $objUser->getPwdHash(), PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(':phone', $objUser->getPhone() ?? "", PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(':work', $objUser->getWork() ?? "", PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(':location', $objUser->getLocation() ?? "", PDO::PARAM_STR);
|
||||
$rqPrep->bindValue(':description', $objUser->getDescription() ?? "", PDO::PARAM_STR);
|
||||
|
||||
|
||||
|
||||
// 3. Executer la requête
|
||||
//var_dump($strRq);die;
|
||||
//return $db->exec($strRq);
|
||||
return $rqPrep->execute();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue