47 lines
No EOL
1.1 KiB
PHP
47 lines
No EOL
1.1 KiB
PHP
<?php
|
|
require_once('mother_model.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();
|
|
|
|
}
|
|
} |