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