From e4003ad37d716022adc538912e90a6b4334a6c33 Mon Sep 17 00:00:00 2001 From: Max Heer Date: Mon, 11 Dec 2023 16:03:00 +0100 Subject: [PATCH] Delete Methode implementiert, nicht getestet --- Controller/EnthaeltController.php | 5 +++++ Model/EnthaeltModel.php | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/Controller/EnthaeltController.php b/Controller/EnthaeltController.php index 65bf83f..7739b5d 100644 --- a/Controller/EnthaeltController.php +++ b/Controller/EnthaeltController.php @@ -16,5 +16,10 @@ $result=$this->db->insertEnthaelt($data); return json_encode($result); } + + public function deleteEnthaelt($id){ + $result=$this->db->deleteEnthaelt($id); + return json_encode($result); + } } ?> \ No newline at end of file diff --git a/Model/EnthaeltModel.php b/Model/EnthaeltModel.php index e296e43..a00546d 100644 --- a/Model/EnthaeltModel.php +++ b/Model/EnthaeltModel.php @@ -48,5 +48,20 @@ return false; } } + + public function deleteEnthaelt($id){ + $pdo=$this->linkDB(); + $params = array(); + $sql = "DELETE FROM Enthaelt WHERE id=:id"; + $params[":id"] = $id; + try{ + $stmt = $pdo->prepare($sql); + $stmt->execute($params); + return true; + } + catch(\PDOExeption $e){ + return false; + } + } } ?> \ No newline at end of file