public function deleteProduct()
 {
     try {
         if (empty($this->id)) {
             throw new Exception('Не задан id товара для удаления');
         }
         $this->setUserIdForDB();
         $st = $this->db->prepare("DELETE FROM image WHERE product_id = ?");
         $st->execute([$this->id]);
         $st = $this->db->prepare("DELETE FROM product WHERE id = ?");
         $st->execute([$this->id]);
         Helper::deleteDir($this->id);
     } catch (Exception $ex) {
         $ex->getMessage();
     }
 }
示例#2
0
 public function deleteSlideAction()
 {
     header('Content-type: text/plain; charset=utf-8');
     header('Cache-Control: no-store, no-cache');
     header('Expires: ' . date('r'));
     if (filter_has_var(INPUT_POST, 'id')) {
         $id = filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT);
     }
     $model = new SliderTableModel();
     $model->setId($id);
     $model->setTable('slider');
     $model->deleteRecord();
     echo Helper::deleteDir($id, 'slider');
 }