public function edit(Product $product) { $query = "Update products Set name = ?, categoryId = ?, price = ?, quantity = ?, editorId = ?\n WHERE products.id = ?"; $params = [$product->getName(), $product->getCategoryId(), $product->getPrice(), $product->getQuantity(), $product->getEditorId(), $product->getId()]; $this->db->query($query, $params); $result = $this->db->row(); return $result; }
public function addToSlider() { $http = new Http(); $return = array(); $id = $http->post('id_new_product'); if (!empty($id)) { $slider_m = new Slider(); $slider_m->setProductId($id); $slider_m->writeData(); $product = new Product($id); $return['id'] = $id; $return['name'] = $product->getName(); $return['img'] = $product->getImage(); $return['price'] = $product->getPrice(); } echo json_encode($return); }
public function updateProduct(Product $product) { $result = $this->db->prepare("\n\t\t\tUPDATE product\n\t\t\tSET name = ?,\n\t\t\t\tquantity = ?,\n\t\t\t\tdescription = ?,\n\t\t\t\tcategory_id = ?\n\t\t\tWHERE id = ?\n\t\t"); $result->execute([$product->getName(), $product->getQuantity(), $product->getDescription(), $product->getCategoryId(), $product->getId()]); }