/** * geeft een lijst van alle Categorie objecten uit de databankt terug * * @param String $locatie * @return array<CategorieId,CategorieNaamNL> */ public static function getCategorien($locatie = "") { $lijst = array(); $db = DB::getDB(); if ($locatie == "") { $statement = $db->prepare("SELECT id FROM categorie"); } else { $statement = $db->prepare("SELECT id FROM categorie WHERE locatie=?"); $statement->bind_param('s', $locatie); } $statement->execute(); $statement->store_result(); $statement->bind_result($id); while ($statement->fetch()) { $cat = new Categorie($id); $lijst[$cat->getId()] = $cat->getNaamNL(); } $statement->close(); return $lijst; }
/** * Ajoute une categorie * @return int id_categorie * @param String $name_categorie */ public function addCategorie($name_categorie, $priorite) { $categorie = new Categorie(0, $this->admin->fundation, html_entity_decode($name_categorie), $priorite); $this->categories[$categorie->getId()] = $categorie; //TODO yaura de l'erreur à gerer ici en cas d'echec ! return $categorie->getId(); }
/** * Permet de Charger tout les Forum d'une catégorie * @param categorie Categorie dont on doit charger les forums * @since 1.0.0 */ public function bindForum(Categorie $categorie) { $sql = "SELECT forum_id id, forum_nom nom, forum_desc`desc`, forum_ordre ordre, forum_view_auth view_auth,\n\t\t\t\tforum_post_auth post_auth, forum_annonce_auth annonce_auth, forum_modo_auth modo_auth\n\t\t\t\tFROM forum\n\t\t\t\tWHERE id_categ = :id"; $id_categ = $categorie->getId(); $req = $this->bdd->prepare($sql); $req->bindParam(":id", $id_categ); $res = $req->execute(); if (!$res) { return false; } $forums = $req->fetchAll(PDO::FETCH_OBJ); foreach ($forums as $forum) { $categorie->addForum(new Forum($forum->id, $forum->nom, $forum->desc, $forum->ordre, NULL, $forum->view_auth, $forum->post_auth, $forum->annonce_auth, $forum->modo_auth)); } }