From 7e034abf8c81359bfaae31b805d09e4851297f69 Mon Sep 17 00:00:00 2001 From: Max Heer Date: Wed, 6 Dec 2023 09:26:20 +0100 Subject: [PATCH 1/4] Bug Fixes bei Enthaelt + Inhaltsstoff erstellt --- Controller/EnthaeltController.php | 6 +++--- Controller/InhaltsstoffController.php | 10 ++++++++++ Model/EnthaeltModel.php | 2 +- Model/InhaltsstoffModel.php | 8 ++++++++ 4 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 Controller/InhaltsstoffController.php create mode 100644 Model/InhaltsstoffModel.php diff --git a/Controller/EnthaeltController.php b/Controller/EnthaeltController.php index b4e4aba..65bf83f 100644 --- a/Controller/EnthaeltController.php +++ b/Controller/EnthaeltController.php @@ -1,10 +1,10 @@ \ No newline at end of file diff --git a/Model/EnthaeltModel.php b/Model/EnthaeltModel.php index f3f4745..e296e43 100644 --- a/Model/EnthaeltModel.php +++ b/Model/EnthaeltModel.php @@ -1,5 +1,5 @@ \ No newline at end of file From e4003ad37d716022adc538912e90a6b4334a6c33 Mon Sep 17 00:00:00 2001 From: Max Heer Date: Mon, 11 Dec 2023 16:03:00 +0100 Subject: [PATCH 2/4] 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 From 5765d49e012b2b73042c3891925ae90df3ac5b08 Mon Sep 17 00:00:00 2001 From: pbs2h22aal Date: Thu, 14 Dec 2023 20:03:29 +0100 Subject: [PATCH 3/4] BestellungUndGericht --- Controller/BestellungController.php | 2 +- Model/BestellungModel.php | 2 +- Model/GerichtModel.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Controller/BestellungController.php b/Controller/BestellungController.php index 2c9a493..5f74cc0 100644 --- a/Controller/BestellungController.php +++ b/Controller/BestellungController.php @@ -5,7 +5,7 @@ namespace ppb\Controller; use ppb\Library\Msg; -use ppb\Model\GerichtModel; +use ppb\Model\BestellungModel; class BestellungController { diff --git a/Model/BestellungModel.php b/Model/BestellungModel.php index c01076a..8327541 100644 --- a/Model/BestellungModel.php +++ b/Model/BestellungModel.php @@ -62,7 +62,7 @@ class BestellungModel extends Database { */ public function updateBestellung($id, $data){ $pdo = $this->linkDB(); - $sql = "UPDATE Bestellung SET " + $sql = "UPDATE Bestellung SET "; //Fügt alle Parameter und einen Platzhalter in den SQL Befehl ein foreach (array_keys($data) as $key){ $sql .= $key . " = :" . $key. ","; diff --git a/Model/GerichtModel.php b/Model/GerichtModel.php index c1bdead..61a1027 100644 --- a/Model/GerichtModel.php +++ b/Model/GerichtModel.php @@ -62,7 +62,7 @@ class GerichtModel extends Database { */ public function updateGericht($id, $data){ $pdo = $this->linkDB(); - $sql = "UPDATE Gericht SET " + $sql = "UPDATE Gericht SET "; //Fügt alle Parameter und einen Platzhalter in den SQL Befehl ein foreach (array_keys($data) as $key){ $sql .= $key . " = :" . $key. ","; From 78ba32377bc44b275b2e736c111ca52db37a9aef Mon Sep 17 00:00:00 2001 From: Max Heer Date: Mon, 18 Dec 2023 08:22:45 +0100 Subject: [PATCH 4/4] =?UTF-8?q?Inhaltsstoff=20vervollst=C3=A4ndigt,=20nich?= =?UTF-8?q?t=20getestet=20nicht=20kommentiert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controller/InhaltsstoffController.php | 15 +++++++- Model/InhaltsstoffModel.php | 54 ++++++++++++++++++++++++++- 2 files changed, 67 insertions(+), 2 deletions(-) diff --git a/Controller/InhaltsstoffController.php b/Controller/InhaltsstoffController.php index 012db9f..45e9c7c 100644 --- a/Controller/InhaltsstoffController.php +++ b/Controller/InhaltsstoffController.php @@ -6,5 +6,18 @@ use VPR_Schnittstelle\Libary\Msg; use VPR_Schnittstelle\Model\InhaltsstoffModel; - + public function getInhaltsstoff(){ + $result=$this->db->getInhaltsstoff(); + return json_encode($result); + } + + public function insertInhaltsstoff($data){ + $result=$this->db->insertInhaltsstoff($data); + return json_encode($result); + } + + public function deleteInhaltsstoff($id){ + $result=$this->db->deleteInhaltsstoff($id); + return json_encode($result); + } ?> \ No newline at end of file diff --git a/Model/InhaltsstoffModel.php b/Model/InhaltsstoffModel.php index 771c8cc..451cecb 100644 --- a/Model/InhaltsstoffModel.php +++ b/Model/InhaltsstoffModel.php @@ -3,6 +3,58 @@ use kindergartenverwaltung\Library\Msg; public function getInhaltsstoff(){ - + $pdo=$this->linkDB(); + $sql = "SELECT * FROM Inhaltsstoff"; + try{ + $stmt = $pdo->prepare($sql); + $stmt->execute(); + } + catch(\PDOExeption $e){ + return false; + } + $result = $stmt->fetchAll(\PDO::FETCH_ASSOC); + + return $result; + } + + public function insertInhaltsstoff($data){ + $pdo=$this->linkDB(); + $params = array(); + $sql = "INSERT INTO Inhaltsstoff "; + 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; + } + } + + public function deleteInhaltsstoff($id){ + $pdo=$this->linkDB(); + $params = array(); + $sql = "DELETE FROM Inhalsstoff 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