diff --git a/Controller/EnthaeltController.php b/Controller/EnthaeltController.php index 0fc1418..efc77ef 100644 --- a/Controller/EnthaeltController.php +++ b/Controller/EnthaeltController.php @@ -1,10 +1,10 @@ prepare($sql); - $stmt->excute($params); + $stmt->execute($params); } catch (\PDOException $e) { return false; } @@ -80,7 +80,7 @@ class BenutzerModel extends Database try { $stmt = $pdo->prepare($sql); - $stmt->excute($params); + $stmt->execute($params); } catch (\PDOException $e) { return false; } diff --git a/Model/EnthaeltModel.php b/Model/EnthaeltModel.php index f3f4745..6d86f61 100644 --- a/Model/EnthaeltModel.php +++ b/Model/EnthaeltModel.php @@ -1,52 +1,53 @@ 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); +use ppb\Library\Msg; - return $result; +class EnthaeltModel extends Database +{ + + public function getEnthaelt($gerichtId) + { + $pdo = $this->linkDB(); + $params = array(); + $sql = "SELECT * FROM Enthaelt WHERE gid = :gerichtId;"; + $params[":gerichtId"] = $gerichtId; + try { + $stmt = $pdo->prepare($sql); + $stmt->execute($params); + } catch (\PDOException $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; } - public function insertEnthaelt($data){ - $pdo=$this->linkDB(); - $params = array(); - $sql = "INSERT INTO Enthaelt ("; + $sql = substr($sql, 0, strlen($sql) - 1) . ");"; - 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; - } + try { + $stmt = $pdo->prepare($sql); + $stmt->execute($params); + return true; + } catch (\PDOException $e) { + return false; } } +} ?> \ No newline at end of file