diff --git a/app/controllers/project_controller.php b/app/controllers/project_controller.php index b8cf009..217cd24 100644 --- a/app/controllers/project_controller.php +++ b/app/controllers/project_controller.php @@ -39,13 +39,10 @@ public function search(){ - //variable pour faire fonctionner le script en footer - $strPage = "search"; - // inclusion du header include('../app/views/partials/header.php'); - //Récupérer les informations du Formulaire + //Récupérer les informations du formulaire $strKeywords = $_POST['keywords']??''; $intAuthor = $_POST['author']??0; $intPeriod = $_POST['period']??0; @@ -56,7 +53,7 @@ // Récupération des projetc $objProjectModel = new ProjectModel; $arrProject = $objProjectModel->findAll(intAuthor:$intAuthor, intPeriod:$intPeriod, strDate:$strDate, - strKeywords:$strKeywords, strStartDate:$strStartDate, strEndDate:$strEndDate, intCategory:$intCategory); + strKeywords:$strKeywords, strStartDate:$strStartDate, strEndDate:$strEndDate, intCategory:$intCategory); // Initialisation d'un tableau => objets $arrProjectToDisplay = array(); diff --git a/app/entities/category_entity.php b/app/entities/category_entity.php index 72ac739..3b51e5b 100644 --- a/app/entities/category_entity.php +++ b/app/entities/category_entity.php @@ -9,8 +9,9 @@ require_once("mother_entity.php"); class Category extends Entity{ - private int $_id; - protected string $_name = ''; + private int $_id; + protected string $_name = ''; + protected string $_parent = ''; /** * Constructeur (j'ai toujours pas compris à quoi ça sert) @@ -53,5 +54,20 @@ class Category extends Entity{ $this->_name = $name; } + /** + * Récuperation du nom du parent de la catégorie + * @return string nom de la catégorie + */ + public function getParent(){ + return $this->_parent; + } + + /** + * Mise à jour du nom du parent de la catégorie + * @param string le nouveau nom de la catégorie + */ + public function setParent($parent){ + $this->_parent = $parent; + } } \ No newline at end of file diff --git a/app/models/category_model.php b/app/models/category_model.php index 4aa3e6c..67c309b 100644 --- a/app/models/category_model.php +++ b/app/models/category_model.php @@ -8,18 +8,40 @@ class CategoryModel extends Connect{ + /** + * Fonction de récupération des catégories + * @return array + */ + 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(); } + + /** + * 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(); + + } } \ No newline at end of file diff --git a/app/models/image_model.php b/app/models/image_model.php index 6c0ca45..438dfbb 100644 --- a/app/models/image_model.php +++ b/app/models/image_model.php @@ -8,9 +8,13 @@ class ImageModel extends Connect{ + /** + * Fonction de récupération des images + * @return array + */ + public function findAllImage(int $intLimit=0):array{ - // Ecrire la requête $strRq = "SELECT image.* FROM image"; @@ -19,7 +23,6 @@ $strRq .= " LIMIT ".$intLimit; } - // Lancer la requête et récupérer les résultats return $this->_db->query($strRq)->fetchAll(); } } \ No newline at end of file diff --git a/app/models/user_model.php b/app/models/user_model.php index 706931b..86c3c19 100644 --- a/app/models/user_model.php +++ b/app/models/user_model.php @@ -58,11 +58,7 @@ public function insert(object $objUser):bool{ // 2. Construire la requête - /*$strRq = "INSERT INTO users (user_name, user_firstname, user_mail, user_pwd) - VALUES ('".$objUser->getName()."', - '".$objUser->getFirstname()."', - '".$objUser->getMail()."', - '".$objUser->getPwdHash()."')";*/ + $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