From ef45413beedab49544a65d9c3493c4240b8bb306 Mon Sep 17 00:00:00 2001 From: Max Heer Date: Wed, 6 Dec 2023 08:53:48 +0100 Subject: [PATCH] Fertig noch nicht getestet --- Controller/EnthaeltController.php | 20 ++++++++++++ Model/EnthaeltModel.php | 52 +++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 Controller/EnthaeltController.php create mode 100644 Model/EnthaeltModel.php diff --git a/Controller/EnthaeltController.php b/Controller/EnthaeltController.php new file mode 100644 index 0000000..b4e4aba --- /dev/null +++ b/Controller/EnthaeltController.php @@ -0,0 +1,20 @@ +db->getEnthaelt($gerichtId); + return json_encode($result); + } + + public function insertEnthaelt($data){ + $result=$this->db->insertEnthaelt($data); + return json_encode($result); + } + } +?> \ No newline at end of file diff --git a/Model/EnthaeltModel.php b/Model/EnthaeltModel.php new file mode 100644 index 0000000..f3f4745 --- /dev/null +++ b/Model/EnthaeltModel.php @@ -0,0 +1,52 @@ +linkDB(); + $params = array(); + $sql = "SELECT * FROM Enthaelt WHERE gid = :gerichtId;"; + $params[":gerichtId"] = gerichtId; + try{ + $stmt = $pdo->prepare($sql); + $stmt->execute($params); + } + catch(\PDOExeption $e){ + return false; + } + $result = $stmt->fetchAll(\PDO::FETCH_ASSOC); + + return $result; + } + + public function insertEnthaelt($data){ + $pdo=$this->linkDB(); + $params = array(); + $sql = "INSERT INTO Enthaelt ("; + + foreach($data as $index=>$value){ + $sql .= "".$index.","; + } + $sql = substr($sql,0,strlen($sql)-1).") VALUES ("; + + foreach($data as $index=>$value){ + $sql .= "':".$index."',"; + $params[":".$index] = $value; + } + + $sql = substr($sql,0,strlen($sql)-1).");"; + + try{ + $stmt = $pdo->prepare($sql); + $stmt->execute($params); + return true; + } + catch(\PDOExeption $e){ + return false; + } + } + } +?> \ No newline at end of file