Пример #1
0
<?php

//ajout d'un topic
if (isset($_POST['titreTopic'], $_POST['send'], $_SESSION['id'], $_GET['id'])) {
    $manager = new CategorieManager($link);
    $categorie = $manager->select($_GET['id']);
    try {
        $topic = $categorie->create($_POST['titreTopic']);
    } catch (Exception $exception) {
        $error = $exception->getMessage();
    }
    if (empty($error)) {
        header('Location: ' . str_replace('index.php', '', $_SERVER['SCRIPT_NAME']) . 'home/' . $categorie->getCategory() . '/' . urlencode($topic->getTitre()));
        exit;
    }
}
//Supression d'un topic
if (isset($_POST['remove'], $_GET['id'])) {
    $manager = new Categorie($link);
    $topic = $manager->selectById($_GET['id']);
    $id = $topic->getId();
    $manager->delete($id);
    header('Location: ' . str_replace('index.php', '', $_SERVER['SCRIPT_NAME']) . 'home/' . $topic->getCategory()->getCategory());
    exit;
}
//modification d'un topic
if (isset($_POST['validate'])) {
    $manager = new Categorie($link);
    $topic = $manager->selectById($_GET['id']);
    try {
        $topic->setTitre($_POST['titreTopic']);
Пример #2
0
 public function getCategory()
 {
     $manager = new CategorieManager($this->link);
     $categorie = $manager->select($this->id_category);
     return $categorie;
 }