public function create($name, $description, $image, Category $category) { $errors = array(); $subCategory = new SubCategory($this->db); $valide = $subCategory->setDescription($description); if ($valide === true) { $valide = $subCategory->setName($name); if ($valide === true) { $valide = $subCategory->setImage($image); if ($valide === true) { $valide = $subCategory->setCategory($category); if ($valide === true) { $description = $this->db->quote($subCategory->getDescription()); $name = $this->db->quote($subCategory->getName()); $image = $this->db->quote($subCategory->getImage()); $id_category = $subCategory->getCategory()->getId(); $query = "INSERT INTO subcategory (description, name, image, id_category) VALUES (" . $description . ", " . $name . ", " . $image . ", " . $id_category . ")"; $res = $this->db->query($query); if ($res) { $id = $this->db->lastInsertId(); if ($id) { try { return $this->findById($id); } catch (Exception $e) { $errors[] = $e->getMessage(); } } else { throw new Exception("internal server error"); } } } else { return $valide; } } else { return $valide; } } else { return $valide; } } else { return $valide; } }
} $priceArray = null; if (isset($_GET['price']) && $_GET['price'] != '') { $priceArray = explode(',', $_GET['price']); $price = $_GET['price']; } ?> <div class="toltip" style="visibility:hidden;position:absolute;cursor:pointer;left:100px;top:50px;border:solid1px#eee;background-color:#ffffdd;padding:10px;z-index:1000;">Le produit a bien été <br> ajouté au panier</div> <section id="columns" class="container_9 clearfix col2-right"> <div class="breadcrumb"> <a title="return to Home" href="home.php">Acceuil</a> <span class="navigation-pipe">/</span> <?php $subCategory = new SubCategory($db, $_GET['idSubCategory']); $category = $subCategory->getCategory(); ?> <a class="return_to_category" href="product-grid.php?idSubCategory=<?php echo $category['id_categorie']; ?> "> <?php echo utf8_encode($category['libelle_cat']); ?> </a> <span class="navigation-pipe">/</span> <?php echo utf8_encode($subCategory->getSubCategoryName()); ?> </div> <div class="category-image"><img src="media/banner1.jpg" width="1170" height="111">