Compare commits
	
		
			36 Commits
		
	
	
		
			stefan
			...
			b6ec972c19
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| b6ec972c19 | |||
| ab9b8ee706 | |||
| 3f5bd9b1bc | |||
| d4c11ef611 | |||
| f0caeb3cfc | |||
| 215ddf86cb | |||
| 7b55e50029 | |||
| c47abaf4bb | |||
| 4b11857f6d | |||
| 7994432aca | |||
| 7bb6d00eb1 | |||
| b104c8a6fc | |||
| 2c63e3c132 | |||
| f96f7c3549 | |||
| 9122289393 | |||
| 23df80f0db | |||
| 78ba32377b | |||
| 3378e66916 | |||
| 621e25ee86 | |||
| c598e48006 | |||
| 5765d49e01 | |||
| c28a3eb452 | |||
| 9f7060d202 | |||
| e4003ad37d | |||
| a915732afd | |||
| 05dcaf2555 | |||
| e190b5bb8d | |||
| 16be7cf3dc | |||
| cab0d36555 | |||
| 62df0fcaf0 | |||
| 6e52a22691 | |||
|   | ac22e2fca4 | ||
| 7e034abf8c | |||
| 2b7811f044 | |||
| 976dc6a3ab | |||
| ef45413bee | 
| @@ -1,31 +1,37 @@ | |||||||
| <?php | <?php | ||||||
|  |  | ||||||
| // Programmiert durch Samuel Wolff | // Programmiert durch Samuel Wolff | ||||||
| // Getestet durch: Nicht getestet | // Getestet durch: Samuel Wolff | ||||||
|  |  | ||||||
| namespace kindergartenverwaltung\Controller; | namespace ppb\Controller; | ||||||
|  |  | ||||||
| use kindergartenverwaltung\Library\Msg; | use ppb\Library\Msg; | ||||||
| use kindergartenverwaltung\Model\BenutzerModel; | use ppb\Model\BenutzerModel; | ||||||
|  |  | ||||||
| class BenutzerController{ | class BenutzerController | ||||||
|  | { | ||||||
|  |  | ||||||
|     private $db; |     private $db; | ||||||
|  |  | ||||||
|     public function __construct(){ |     public function __construct() | ||||||
|  |     { | ||||||
|         $this->db = new BenutzerModel(); |         $this->db = new BenutzerModel(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function updateBenutzer($elternId, $data){ |     // Updated einen Benutzer | ||||||
|  |     public function updateBenutzer($elternId, $data) | ||||||
|  |     { | ||||||
|  |  | ||||||
|         $result = $this->db->updateBenutzer($benutzerId, $data); |         $result = $this->db->updateBenutzer($elternId, $data); | ||||||
|  |  | ||||||
|         return json_encode($result); |         return json_encode($result); | ||||||
|  |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function insertBenutzer($data){ |     // Fügt einen Benutzer in die Datenbank hinzu | ||||||
|         $result = $this->db->insertBenutzer($data) |     public function writeBenutzer($data) | ||||||
|  |     { | ||||||
|  |         $result = $this->db->insertBenutzer($data); | ||||||
|  |  | ||||||
|         return json_encode($data); |         return json_encode($data); | ||||||
|     } |     } | ||||||
|   | |||||||
							
								
								
									
										50
									
								
								Controller/BestellungController.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								Controller/BestellungController.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,50 @@ | |||||||
|  | <?php | ||||||
|  | //Programmierung: Sven Alteköster 100% | ||||||
|  | //Getestet durch: Sven Alteköster 100% | ||||||
|  |  | ||||||
|  | namespace ppb\Controller; | ||||||
|  |  | ||||||
|  | use ppb\Library\Msg; | ||||||
|  | use ppb\Model\BestellungModel; | ||||||
|  |  | ||||||
|  | class BestellungController | ||||||
|  | { | ||||||
|  |  | ||||||
|  |   private $db; | ||||||
|  |  | ||||||
|  |   public function __construct() | ||||||
|  |   { | ||||||
|  |     $this->db = new BestellungModel(); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   public function getBestellung($id = false) | ||||||
|  |   { | ||||||
|  |     $result = $this->db->selectBestellung($id); | ||||||
|  |     if ($id !== false) { | ||||||
|  |       if ($result) | ||||||
|  |         $result = $result[0]; | ||||||
|  |       else | ||||||
|  |         $result = false; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     return json_encode($result); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   public function writeBestellung($data) | ||||||
|  |   { | ||||||
|  |     $result = $this->db->insertBestellung($data); | ||||||
|  |     return json_encode($result); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   public function updateBestellung($id, $data) | ||||||
|  |   { | ||||||
|  |     $result = $this->db->updateBestellung($id, $data); | ||||||
|  |     return json_encode($result); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   public function deleteBestellung($id) | ||||||
|  |   { | ||||||
|  |     $result = $this->db->deleteBestellung($id); | ||||||
|  |     return json_encode($result); | ||||||
|  |   } | ||||||
|  | } | ||||||
							
								
								
									
										31
									
								
								Controller/EnthaeltController.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								Controller/EnthaeltController.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,31 @@ | |||||||
|  | <?php | ||||||
|  | //Programmiert von: Max Heer, Getestet von: Samuel Wolff | ||||||
|  |  | ||||||
|  | namespace ppb\Controller; | ||||||
|  |  | ||||||
|  | use ppb\Libary\Msg; | ||||||
|  | use ppb\Model\EnthaeltModel; | ||||||
|  |  | ||||||
|  | class EnthaeltController | ||||||
|  | { | ||||||
|  |  | ||||||
|  |     private $db; | ||||||
|  |  | ||||||
|  |     public function __construct() | ||||||
|  |     { | ||||||
|  |         $this->db = new EnthaeltModel(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public function getEnthaelt($gerichtId) | ||||||
|  |     { | ||||||
|  |         $result = $this->db->getEnthaelt($gerichtId); | ||||||
|  |         return json_encode($result); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public function writeEnthaelt($data) | ||||||
|  |     { | ||||||
|  |         $result = $this->db->insertEnthaelt($data); | ||||||
|  |         return json_encode($result); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?> | ||||||
							
								
								
									
										32
									
								
								Controller/FilterController.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								Controller/FilterController.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,32 @@ | |||||||
|  | <?php | ||||||
|  | //Erstellt durch Stefan Groß - Samuel Wolff | ||||||
|  | namespace ppb\Controller; | ||||||
|  |  | ||||||
|  | use ppb\Model\FilterModel; | ||||||
|  |  | ||||||
|  | class FilterController | ||||||
|  | { | ||||||
|  |     private $db; | ||||||
|  |  | ||||||
|  |     public function __construct() | ||||||
|  |     { | ||||||
|  |  | ||||||
|  |         $this->db = new FilterModel(); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public function writeFilter($data) | ||||||
|  |     { | ||||||
|  |         $results = $this->db->insertFilter($data); | ||||||
|  |  | ||||||
|  |         return json_encode($results); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public function deleteFilter($id) | ||||||
|  |     { | ||||||
|  |         $results = $this->db->deleteFilter($id); | ||||||
|  |  | ||||||
|  |         return json_encode($results); | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										44
									
								
								Controller/GerichtController.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								Controller/GerichtController.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,44 @@ | |||||||
|  | <?php | ||||||
|  | //Programmierung: Sven Alteköster 100% | ||||||
|  | //Getestet durch: Sven Alteköster 100% | ||||||
|  |  | ||||||
|  | namespace ppb\Controller; | ||||||
|  |  | ||||||
|  | use ppb\Library\Msg; | ||||||
|  | use ppb\Model\GerichtModel; | ||||||
|  |  | ||||||
|  | class GerichtController { | ||||||
|  |      | ||||||
|  | 	private $db; | ||||||
|  | 	 | ||||||
|  | 	public function __construct() {	   | ||||||
|  |         $this->db = new GerichtModel();	   	   | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public function getGericht($id=false) { | ||||||
|  |         $result=$this->db->selectGericht($id); | ||||||
|  |         if($id !== false){ | ||||||
|  |           if($result) | ||||||
|  |             $result=$result[0]; | ||||||
|  |           else | ||||||
|  |             $result=false; | ||||||
|  |         } | ||||||
|  |    | ||||||
|  |         return json_encode($result); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public function writeGericht($data){ | ||||||
|  |       $result=$this->db->insertGericht($data); | ||||||
|  |       return json_encode($result); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public function updateGericht($id, $data){ | ||||||
|  |       $result=$this->db->updateGericht($id, $data); | ||||||
|  |       return json_encode($result); | ||||||
|  |     } | ||||||
|  |    | ||||||
|  |     public function deleteGericht($id){ | ||||||
|  |       $result=$this->db->deleteGericht($id); | ||||||
|  |       return json_encode($result); | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										42
									
								
								Controller/GibtsAmController.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								Controller/GibtsAmController.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,42 @@ | |||||||
|  | <?php | ||||||
|  | //Erstellt durch Stefan Groß - Getestet von Samuel Wolff | ||||||
|  | namespace ppb\Controller; | ||||||
|  |  | ||||||
|  | use ppb\Model\GibtsAmModel; | ||||||
|  |  | ||||||
|  | class GibtsAmController | ||||||
|  | { | ||||||
|  |     private $db; | ||||||
|  |  | ||||||
|  |     public function __construct() | ||||||
|  |     { | ||||||
|  |  | ||||||
|  |         $this->db = new GibtsAmModel(); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public function getGibtsAm() | ||||||
|  |     { | ||||||
|  |         $result = $this->db->selectGibtsAm(); | ||||||
|  |  | ||||||
|  |         return json_encode($result); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public function writeGibtsAm($data) | ||||||
|  |     { | ||||||
|  |         $result = $this->db->insertGibtsAm($data); | ||||||
|  |  | ||||||
|  |         return json_encode($result); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public function deleteGibtsAm($id) | ||||||
|  |     { | ||||||
|  |         $result = $this->db->deleteGibtsAm($id); | ||||||
|  |  | ||||||
|  |         return json_encode($result); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ?> | ||||||
							
								
								
									
										38
									
								
								Controller/InhaltsstoffController.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								Controller/InhaltsstoffController.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,38 @@ | |||||||
|  | <?php | ||||||
|  | //Programmiert von: Max Heer, Getestet von: Samuel Wolff | ||||||
|  |  | ||||||
|  | namespace ppb\Controller; | ||||||
|  |  | ||||||
|  | use ppb\Libary\Msg; | ||||||
|  | use ppb\Model\InhaltsstoffModel; | ||||||
|  |  | ||||||
|  | class InhaltsstoffController | ||||||
|  | { | ||||||
|  |  | ||||||
|  |     private $db; | ||||||
|  |  | ||||||
|  |     public function __construct() | ||||||
|  |     { | ||||||
|  |         $this->db = new InhaltsstoffModel(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     public function getInhaltsstoff() | ||||||
|  |     { | ||||||
|  |         $result = $this->db->getInhaltsstoff(); | ||||||
|  |         return json_encode($result); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public function writeInhaltsstoff($data) | ||||||
|  |     { | ||||||
|  |         $result = $this->db->insertInhaltsstoff($data); | ||||||
|  |         return json_encode($result); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public function deleteInhaltsstoff($id) | ||||||
|  |     { | ||||||
|  |         $result = $this->db->deleteInhaltsstoff($id); | ||||||
|  |         return json_encode($result); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?> | ||||||
| @@ -1,42 +1,51 @@ | |||||||
| <?php | <?php | ||||||
|  |  | ||||||
| // Programmiert durch Samuel Wolff | // Programmiert durch Samuel Wolff | ||||||
| // Getestet durch: Nicht getestet | // Getestet durch: Samuel Wolff | ||||||
|  |  | ||||||
| namespace kindergartenverwaltung\Controller; | namespace ppb\Controller; | ||||||
|  |  | ||||||
| use kindergartenverwaltung\Library\Msg; | use ppb\Library\Msg; | ||||||
| use kindergartenverwaltung\Model\KindModel; | use ppb\Model\KindModel; | ||||||
|  |  | ||||||
| class KindController{ | class KindController | ||||||
|  | { | ||||||
|  |  | ||||||
|     private $db; |     private $db; | ||||||
|  |  | ||||||
|     public function __construct(){ |     public function __construct() | ||||||
|  |     { | ||||||
|         $this->db = new KindModel(); |         $this->db = new KindModel(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // $parentId ist standardmäßig auf false und gibt damit alle Kinder aus, |     // $parentId ist standardmäßig auf false und gibt damit alle Kinder aus, | ||||||
|     // das setzen gibt nur Kinder eines bestimmten Benutzerkontos aus. |     // das setzen gibt nur Kinder eines bestimmten Benutzerkontos aus. | ||||||
|     public function getKind($parentId = false){ |     public function getKind($parentId = false) | ||||||
|  |     { | ||||||
|         $result = $this->db->getKind($parentId); |         $result = $this->db->getKind($parentId); | ||||||
|  |  | ||||||
|         return json_encode($result); |         return json_encode($result); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function updateKind($kindId, $data){ |     // Updated ein Kind | ||||||
|  |     public function updateKind($kindId, $data) | ||||||
|  |     { | ||||||
|         $result = $this->db->updateKind($kindId, $data); |         $result = $this->db->updateKind($kindId, $data); | ||||||
|  |  | ||||||
|         return json_encode($result); |         return json_encode($result); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function addKind($data){ |     // Fügt ein Kind hinzu | ||||||
|  |     public function writeKind($data) | ||||||
|  |     { | ||||||
|         $result = $this->db->addKind($data); |         $result = $this->db->addKind($data); | ||||||
|  |  | ||||||
|         return json_encode($data); |         return json_encode($data); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function deleteKind($kindId){ |     // Löscht ein Kind | ||||||
|  |     public function deleteKind($kindId) | ||||||
|  |     { | ||||||
|         $result = $this->db->deleteKind($kindId); |         $result = $this->db->deleteKind($kindId); | ||||||
|  |  | ||||||
|         return $result; |         return $result; | ||||||
|   | |||||||
							
								
								
									
										37
									
								
								Controller/TagesplanController.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								Controller/TagesplanController.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,37 @@ | |||||||
|  | <?php | ||||||
|  | //Programmiert von: Max Heer, Getestet von: Samuel Wolff | ||||||
|  |  | ||||||
|  | namespace ppb\Controller; | ||||||
|  |  | ||||||
|  | use ppb\Libary\Msg; | ||||||
|  | use ppb\Model\TagesplanModel; | ||||||
|  |  | ||||||
|  | class TagesplanController | ||||||
|  | { | ||||||
|  |  | ||||||
|  |     private $db; | ||||||
|  |  | ||||||
|  |     public function __construct() | ||||||
|  |     { | ||||||
|  |         $this->db = new TagesplanModel(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public function getTagesplan() | ||||||
|  |     { | ||||||
|  |         $result = $this->db->getTagesplan(); | ||||||
|  |         return json_encode($result); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public function writeTagesplan($data) | ||||||
|  |     { | ||||||
|  |         $result = $this->db->insertTagesplan($data); | ||||||
|  |         return json_encode($result); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public function deleteTagesplan($id) | ||||||
|  |     { | ||||||
|  |         $result = $this->db->deleteTagesplan($id); | ||||||
|  |         return json_encode($result); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?> | ||||||
| @@ -1,21 +1,40 @@ | |||||||
| <?php | <?php | ||||||
| // Erstellt durch Stefan Groß | // Erstellt durch Stefan Groß - Getestet von Samuel Wolff | ||||||
| namespace kinderverwaltung\Controller; | namespace ppb\Controller; | ||||||
|  |  | ||||||
| class istTeilController { | use ppb\Model\IstTeilModel; | ||||||
|  |  | ||||||
|  | class istTeilController | ||||||
|  | { | ||||||
|     private $db; |     private $db; | ||||||
|  |  | ||||||
|     public function __construct() |     public function __construct() | ||||||
|     { |     { | ||||||
|  |  | ||||||
|         $this-> db = new istTeilModel(); |         $this->db = new istTeilModel(); | ||||||
|  |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function getBestellung(){ |     public function getIstTeil() | ||||||
|         $result = $this->db->getBestellung(); |     { | ||||||
|  |         $result = $this->db->selectIstTeil(); | ||||||
|  |  | ||||||
|         return json_encode($result); |         return json_encode($result); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     public function writeIstTeil($data) | ||||||
|  |     { | ||||||
|  |         $result = $this->db->insertIstTeil($data); | ||||||
|  |  | ||||||
|  |         return json_encode($result); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public function deleteIstTeil($id) | ||||||
|  |     { | ||||||
|  |         $result = $this->db->deleteIstTeil($id); | ||||||
|  |  | ||||||
|  |         return json_encode($result); | ||||||
|  |     } | ||||||
|  |  | ||||||
| } | } | ||||||
| ?> | ?> | ||||||
| @@ -1,36 +1,47 @@ | |||||||
| <?php | <?php | ||||||
|  |  | ||||||
| // Programmiert durch Samuel Wolff | // Programmiert durch Samuel Wolff | ||||||
| // Getestet durch: Nicht getestet | // Getestet durch: Samuel Wolff | ||||||
|  |  | ||||||
| namespace kindergartenverwaltung\Controller; | namespace ppb\Model; | ||||||
|  |  | ||||||
| use kindergartenverwaltung\Library\Msg; | use ppb\Library\Msg; | ||||||
| use kindergartenverwaltung\Model\BenutzerModel; |  | ||||||
|  |  | ||||||
| class BenutzerModel extends Database{ | class BenutzerModel extends Database | ||||||
|  | { | ||||||
|  |  | ||||||
|     public function updateBenutzer($elternId, $data){ |  | ||||||
|  |     /** | ||||||
|  |      *  | ||||||
|  |      * Updated einen Benutzer | ||||||
|  |      *  | ||||||
|  |      * @param $elternId Die Id des Elternaccounts | ||||||
|  |      * @param $data Die gegebenen Daten | ||||||
|  |      *  | ||||||
|  |      */ | ||||||
|  |     public function updateBenutzer($elternId, $data) | ||||||
|  |     { | ||||||
|         $pdo = $this->linkDB(); |         $pdo = $this->linkDB(); | ||||||
|  |  | ||||||
|         $params = array(); |         $params = array(); | ||||||
|  |  | ||||||
|         $sql = "UPDATE Benutzer SET" |         $sql = "UPDATE Benutzerkonto SET"; | ||||||
|  |  | ||||||
|         foreach($data as $index=>$value){ |         foreach ($data as $index => $value) { | ||||||
|             $sql .= " ".$index." = :".$index; |             $sql .= " " . $index . " = :" . $index . ","; | ||||||
|             $params[":".$index] = $value; |             $params[":" . $index] = $value; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         $sql .= " WHERE id = :benutzerId;"; |         $sql = substr($sql, 0, strlen($sql) - 1) . " WHERE id = :benutzerId;"; | ||||||
|  |  | ||||||
|         $params[":benutzerId"] = $kindId; |         $params[":benutzerId"] = $elternId; | ||||||
|  |  | ||||||
|         try{ |         try { | ||||||
|             $stmt = $pdo->prepare($sql); |             $stmt = $pdo->prepare($sql); | ||||||
|             $stmt->excute($params); |             $stmt->execute($params); | ||||||
|         } |         } catch (\PDOException $e) { | ||||||
|         catch(\PDOException $e){ |             echo $sql; | ||||||
|  |             echo json_encode($params); | ||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -40,32 +51,41 @@ class BenutzerModel extends Database{ | |||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|     public function insertBenutzer($data){ |     /** | ||||||
|  |      *  | ||||||
|  |      * Fügt einen neuen Benutzer in der Datenbank hinzu | ||||||
|  |      *  | ||||||
|  |      * @param $data Die gegebenen Daten | ||||||
|  |      *  | ||||||
|  |      */ | ||||||
|  |     public function insertBenutzer($data) | ||||||
|  |     { | ||||||
|         $pdo = $this->linkDB(); |         $pdo = $this->linkDB(); | ||||||
|  |  | ||||||
|         $params = array(); |         $params = array(); | ||||||
|  |  | ||||||
|         $sql = "INSERT INTO Benutzer ("; |         $sql = "INSERT INTO Benutzerkonto ("; | ||||||
|  |  | ||||||
|         foreach($data as $index=>$value){ |         foreach ($data as $index => $value) { | ||||||
|             $sql .= $index.", "; |             $sql .= $index . ", "; | ||||||
|             $params[":"+$index] = $index; |             $params[":" . $index] = $index; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         $sql = substr($sql, 0, strlen($sql)-2).") VALUES ("; |         $sql = substr($sql, 0, strlen($sql) - 2) . ") VALUES ("; | ||||||
|  |  | ||||||
|         foreach($data as $value){ |         foreach ($data as $index => $value) { | ||||||
|             $sql .= ":".$value." ,"; |             $sql .= ":" . $index . " ,"; | ||||||
|             $params[":"+$value] = $value; |             $params[":" . $index] = $value; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         $sql = substr($sql, 0, strlen($sql)-2).");"; |         $sql = substr($sql, 0, strlen($sql) - 2) . ");"; | ||||||
|  |  | ||||||
|         try{ |         echo $sql; | ||||||
|  |  | ||||||
|  |         try { | ||||||
|             $stmt = $pdo->prepare($sql); |             $stmt = $pdo->prepare($sql); | ||||||
|             $stmt->excute($params); |             $stmt->execute($params); | ||||||
|         } |         } catch (\PDOException $e) { | ||||||
|         catch(\PDOException $e){ |  | ||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										109
									
								
								Model/BestellungModel.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										109
									
								
								Model/BestellungModel.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,109 @@ | |||||||
|  | <?php | ||||||
|  | //Programmierung: Sven Alteköster 100% | ||||||
|  | //Getestet durch: Sven Alteköster 100% | ||||||
|  |  | ||||||
|  | namespace ppb\Model; | ||||||
|  |  | ||||||
|  | use ppb\Library\Msg; | ||||||
|  |  | ||||||
|  | class BestellungModel extends Database | ||||||
|  | { | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Sucht die Bestellung in der Datenbank und gibt diese im json-Format zurück. | ||||||
|  |      * @param $id gibt die id, des Benutzerkontos an, über den die Bestellung getätigt wurde. Wenn keine id angegeben wird, werden alle Einträge ausgegeben | ||||||
|  |      */ | ||||||
|  |     public function selectBestellung($id = false) | ||||||
|  |     { | ||||||
|  |         $pdo = $this->linkDB(); | ||||||
|  |         $sql = "SELECT Bestellung.id, Bestellung.istBezahlt, Bestellung.bestelldatum, Bestellung.gesamtpreis, Bestellung.kid FROM Bestellung"; | ||||||
|  |         $params = array(); | ||||||
|  |         //Ist eine id angegeben wird der Datensatz in der Datenbank gesucht | ||||||
|  |         if ($id !== false) { | ||||||
|  |             $sql .= " INNER JOIN Kind k ON k.id = kid INNER JOIN Benutzerkonto b ON b.id = bid"; | ||||||
|  |             $sql .= " WHERE bid = :bid"; | ||||||
|  |             $params["bid"] = $id; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         //Ausführen des SQL befehls | ||||||
|  |         try { | ||||||
|  |             $stmt = $pdo->prepare($sql); | ||||||
|  |             $stmt->execute($params); | ||||||
|  |         } catch (\PDOException $e) { | ||||||
|  |             echo $e; | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  |         $result = $stmt->fetchAll(\PDO::FETCH_ASSOC); | ||||||
|  |  | ||||||
|  |         //Die Datensätze werden nummeriert | ||||||
|  |         foreach ($result as $key => $row) { | ||||||
|  |             $result[$key]["id"] += 0; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         return $result; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Fügt ein Bestellung in die Datenbank ein. | ||||||
|  |      * @param $data gibt die Attribute des Datensatzes an. | ||||||
|  |      */ | ||||||
|  |     public function insertBestellung($data) | ||||||
|  |     { | ||||||
|  |         $pdo = $this->linkDB(); | ||||||
|  |         $sql = "INSERT INTO Bestellung (" . implode(",", array_keys($data)) . ") VALUES(:" . implode(",:", array_keys($data)) . ")"; | ||||||
|  |  | ||||||
|  |         try { | ||||||
|  |             $stmt = $pdo->prepare($sql); | ||||||
|  |             $result = $stmt->execute($data); | ||||||
|  |         } catch (\PDOException $e) { | ||||||
|  |             echo $e; | ||||||
|  |         } | ||||||
|  |         return $result; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Updatet einen Datensatz in der Bestellung Tabelle. | ||||||
|  |      * @param $id des Datensatzes | ||||||
|  |      * @param $data neue Parameter des Datensatzes | ||||||
|  |      */ | ||||||
|  |     public function updateBestellung($id, $data) | ||||||
|  |     { | ||||||
|  |         $pdo = $this->linkDB(); | ||||||
|  |         $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 . ","; | ||||||
|  |         } | ||||||
|  |         $sql = substr_replace($sql, "", -1) . " WHERE id = :id"; | ||||||
|  |         $data["id"] = $id; | ||||||
|  |         try { | ||||||
|  |             $stmt = $pdo->prepare($sql); | ||||||
|  |             $result = $stmt->execute($data); | ||||||
|  |         } catch (\PDOException $e) { | ||||||
|  |             echo $e; | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  |         return $result; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Löscht ein Bestellung aus der Tabelle | ||||||
|  |      * @param $id des zu löschenden Bestellung | ||||||
|  |      */ | ||||||
|  |     public function deleteBestellung($id) | ||||||
|  |     { | ||||||
|  |         $pdo = $this->linkDB(); | ||||||
|  |         $sql = "DELETE FROM Bestellung WHERE id = :id"; | ||||||
|  |         $params = array(); | ||||||
|  |         $params[":id"] = $id; | ||||||
|  |         try { | ||||||
|  |             $stmt = $pdo->prepare($sql); | ||||||
|  |             $result = $stmt->execute($params); | ||||||
|  |         } catch (\PDOException $e) { | ||||||
|  |             echo $e; | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  |         return $result; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -9,7 +9,7 @@ abstract class Database { | |||||||
|     /** |     /** | ||||||
|      * Zugangsdaten für die Datenbank  |      * Zugangsdaten für die Datenbank  | ||||||
|      */ |      */ | ||||||
|     private $dbName = "pbs2h22aal_av"; //Datenbankname |     private $dbName = "pbs2h22aal_SubwaySurfers"; //Datenbankname | ||||||
|     private $linkName = "mysql.pb.bib.de"; //Datenbank-Server |     private $linkName = "mysql.pb.bib.de"; //Datenbank-Server | ||||||
| 	//Administration: https://mysql.pb.bib.de/phpMyAdmin/ | 	//Administration: https://mysql.pb.bib.de/phpMyAdmin/ | ||||||
|     private $user = "pbs2h22aal"; //Benutzername |     private $user = "pbs2h22aal"; //Benutzername | ||||||
|   | |||||||
							
								
								
									
										58
									
								
								Model/EnthaeltModel.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								Model/EnthaeltModel.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,58 @@ | |||||||
|  | <?php | ||||||
|  |  | ||||||
|  | //Programmiert von: Max Heer, Getestet von: Samuel Wolff | ||||||
|  |  | ||||||
|  | namespace ppb\Model; | ||||||
|  |  | ||||||
|  | use ppb\Library\Msg; | ||||||
|  |  | ||||||
|  | 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; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         $sql = substr($sql, 0, strlen($sql) - 1) . ");"; | ||||||
|  |  | ||||||
|  |         echo $sql; | ||||||
|  |  | ||||||
|  |         try { | ||||||
|  |             $stmt = $pdo->prepare($sql); | ||||||
|  |             $stmt->execute($params); | ||||||
|  |             return true; | ||||||
|  |         } catch (\PDOException $e) { | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?> | ||||||
							
								
								
									
										52
									
								
								Model/FilterModel.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								Model/FilterModel.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,52 @@ | |||||||
|  | <?php | ||||||
|  |  | ||||||
|  | namespace ppb\Model; | ||||||
|  |  | ||||||
|  | use ppb\Model\Database; | ||||||
|  |  | ||||||
|  | //Erstellt durch Stefan Groß - Samuel Wolff | ||||||
|  |  | ||||||
|  | class FilterModel extends Database | ||||||
|  | { | ||||||
|  |  | ||||||
|  |     public function insertFilter($data) | ||||||
|  |     { | ||||||
|  |         $pdo = $this->linkDB(); | ||||||
|  |  | ||||||
|  |         $params = array(); | ||||||
|  |  | ||||||
|  |         $sql = "INSERT INTO Filter (kid, iid) VALUES (:kid, :iid)"; | ||||||
|  |  | ||||||
|  |         $params[":kid"] = $data["kid"]; | ||||||
|  |         $params[":iid"] = $data["iid"]; | ||||||
|  |  | ||||||
|  |         try { | ||||||
|  |             $stmt = $pdo->prepare($sql); | ||||||
|  |             $stmt->execute($params); | ||||||
|  |         } catch (\PDOException $e) { | ||||||
|  |             echo $sql; | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  |         return true; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public function deleteFilter($id) | ||||||
|  |     { | ||||||
|  |         $pdo = $this->linkDB(); | ||||||
|  |  | ||||||
|  |         $params = array(); | ||||||
|  |  | ||||||
|  |         $sql = "DELETE FROM Filter WHERE id = :id"; | ||||||
|  |  | ||||||
|  |         $params[":id"] = $id; | ||||||
|  |  | ||||||
|  |         try { | ||||||
|  |             $stmt = $pdo->prepare($sql); | ||||||
|  |             $stmt->execute($params); | ||||||
|  |         } catch (\PDOException $e) { | ||||||
|  |             echo $sql; | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  |         return true; | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										107
									
								
								Model/GerichtModel.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										107
									
								
								Model/GerichtModel.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,107 @@ | |||||||
|  | <?php | ||||||
|  | //Programmierung: Sven Alteköster 100% | ||||||
|  | //Getestet durch: Sven Alteköster 100% | ||||||
|  |  | ||||||
|  | namespace ppb\Model; | ||||||
|  |  | ||||||
|  | use ppb\Library\Msg; | ||||||
|  |  | ||||||
|  | class GerichtModel extends Database | ||||||
|  | { | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Sucht die Gerichte in der Datenbank und gibt diese im json-Format zurück. | ||||||
|  |      * @param $id gibt die id, des gesuchten Objektes an. Wenn keine id angegeben wird, werden alle Einträge ausgegeben | ||||||
|  |      */ | ||||||
|  |     public function selectGericht($id = false) | ||||||
|  |     { | ||||||
|  |         $pdo = $this->linkDB(); | ||||||
|  |         $sql = "SELECT * FROM Gericht"; | ||||||
|  |         $params = array(); | ||||||
|  |         //Ist eine id angegeben wird der Datensatz in der Datenbank gesucht | ||||||
|  |         if ($id !== false) { | ||||||
|  |             $sql .= " WHERE id = :id"; | ||||||
|  |             $params["id"] = $id; | ||||||
|  |         } | ||||||
|  |         //Ausführen des SQL befehls | ||||||
|  |         try { | ||||||
|  |             $stmt = $pdo->prepare($sql); | ||||||
|  |             $stmt->execute($params); | ||||||
|  |         } catch (\PDOException $e) { | ||||||
|  |             echo $e; | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  |         $result = $stmt->fetchAll(\PDO::FETCH_ASSOC); | ||||||
|  |  | ||||||
|  |         //Die Datensätze werden nummeriert | ||||||
|  |         foreach ($result as $key => $row) { | ||||||
|  |             $result[$key]["id"] += 0; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         return $result; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Fügt ein Gericht in die Datenbank ein. | ||||||
|  |      * @param $data gibt die Attribute des Datensatzes an. | ||||||
|  |      */ | ||||||
|  |     public function insertGericht($data) | ||||||
|  |     { | ||||||
|  |         $pdo = $this->linkDB(); | ||||||
|  |         $sql = "INSERT INTO Gericht (" . implode(",", array_keys($data)) . ") VALUES(:" . implode(",:", array_keys($data)) . ")"; | ||||||
|  |  | ||||||
|  |         try { | ||||||
|  |             $stmt = $pdo->prepare($sql); | ||||||
|  |             $result = $stmt->execute($data); | ||||||
|  |         } catch (\PDOException $e) { | ||||||
|  |             echo $e; | ||||||
|  |         } | ||||||
|  |         return $result; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Updatet einen Datensatz in der Gericht Tabelle. | ||||||
|  |      * @param $id des Datensatzes | ||||||
|  |      * @param $data neue Parameter des Datensatzes | ||||||
|  |      */ | ||||||
|  |     public function updateGericht($id, $data) | ||||||
|  |     { | ||||||
|  |         $pdo = $this->linkDB(); | ||||||
|  |         $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 . ","; | ||||||
|  |         } | ||||||
|  |         $sql = substr_replace($sql, "", -1) . " WHERE id = :id"; | ||||||
|  |         $data["id"] = $id; | ||||||
|  |         try { | ||||||
|  |             $stmt = $pdo->prepare($sql); | ||||||
|  |             $result = $stmt->execute($data); | ||||||
|  |         } catch (\PDOException $e) { | ||||||
|  |             echo $e; | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  |         return $result; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Löscht ein Gericht aus der Tabelle | ||||||
|  |      * @param $id des zu löschenden Gerichtes | ||||||
|  |      */ | ||||||
|  |     public function deleteGericht($id) | ||||||
|  |     { | ||||||
|  |         $pdo = $this->linkDB(); | ||||||
|  |         $sql = "DELETE FROM Gericht WHERE id = :id"; | ||||||
|  |         $params = array(); | ||||||
|  |         $params[":id"] = $id; | ||||||
|  |         try { | ||||||
|  |             $stmt = $pdo->prepare($sql); | ||||||
|  |             $result = $stmt->execute($params); | ||||||
|  |         } catch (\PDOException $e) { | ||||||
|  |             echo $e; | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  |         return $result; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | } | ||||||
							
								
								
									
										74
									
								
								Model/GibtsAmModel.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										74
									
								
								Model/GibtsAmModel.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,74 @@ | |||||||
|  | <?php | ||||||
|  |  | ||||||
|  | namespace ppb\Model; | ||||||
|  |  | ||||||
|  | //Programmiert von Stefan Groß - Getestet von Samuel Wolff | ||||||
|  |  | ||||||
|  | class GibtsAmModel extends Database | ||||||
|  | { | ||||||
|  |  | ||||||
|  |     public function selectGibtsAm() | ||||||
|  |     { | ||||||
|  |         $pdo = $this->linkDB(); | ||||||
|  |  | ||||||
|  |         $sql = "SELECT * FROM GibtsAm"; | ||||||
|  |  | ||||||
|  |         try { | ||||||
|  |             $stmt = $pdo->prepare($sql); | ||||||
|  |             $stmt->execute(); | ||||||
|  |         } catch (\PDOException $e) { | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         $results = $stmt->fetchAll(\PDO::FETCH_ASSOC); | ||||||
|  |  | ||||||
|  |         foreach ($results as $key => $value) { | ||||||
|  |             $results[$key]["id"] += 0; | ||||||
|  |             $results[$key]["tid"] += 0; | ||||||
|  |             $results[$key]["gid"] += 0; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         return $results; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public function insertGibtsAm($data) | ||||||
|  |     { | ||||||
|  |         $pdo = $this->linkDB(); | ||||||
|  |  | ||||||
|  |         $params = array(); | ||||||
|  |  | ||||||
|  |         $sql = "INSERT INTO GibtsAm (tid, gid) VALUES (:tid, :gid)"; | ||||||
|  |         $params[":tid"] = $data["tid"]; | ||||||
|  |         $params[":gid"] = $data["gid"]; | ||||||
|  |  | ||||||
|  |         try { | ||||||
|  |             $stmt = $pdo->prepare($sql); | ||||||
|  |             $stmt->execute($params); | ||||||
|  |         } catch (\PDOException $e) { | ||||||
|  |             echo $sql; | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  |         return true; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public function deleteGibtsAm($id) | ||||||
|  |     { | ||||||
|  |         $pdo = $this->linkDB(); | ||||||
|  |  | ||||||
|  |         $params = array(); | ||||||
|  |  | ||||||
|  |         $sql = "DELETE FROM GibtsAm WHERE id = :id"; | ||||||
|  |  | ||||||
|  |         $params[":id"] = $id; | ||||||
|  |  | ||||||
|  |         try { | ||||||
|  |             $stmt = $pdo->prepare($sql); | ||||||
|  |             $stmt->execute($params); | ||||||
|  |         } catch (\PDOException $e) { | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  |         return true; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
|  | ?> | ||||||
							
								
								
									
										70
									
								
								Model/InhaltsstoffModel.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								Model/InhaltsstoffModel.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,70 @@ | |||||||
|  | <?php | ||||||
|  | // Programmiert von Max Heer | ||||||
|  | // Getestet von Samuel Wolff | ||||||
|  |  | ||||||
|  | namespace ppb\Model; | ||||||
|  |  | ||||||
|  | use ppb\Library\Msg; | ||||||
|  |  | ||||||
|  | class InhaltsstoffModel extends Database | ||||||
|  | { | ||||||
|  |  | ||||||
|  |     public function getInhaltsstoff() | ||||||
|  |     { | ||||||
|  |         $pdo = $this->linkDB(); | ||||||
|  |         $sql = "SELECT * FROM Inhaltsstoff"; | ||||||
|  |         try { | ||||||
|  |             $stmt = $pdo->prepare($sql); | ||||||
|  |             $stmt->execute(); | ||||||
|  |         } catch (\PDOException $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 (\PDOException $e) { | ||||||
|  |             echo $sql; | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public function deleteInhaltsstoff($id) | ||||||
|  |     { | ||||||
|  |         $pdo = $this->linkDB(); | ||||||
|  |         $params = array(); | ||||||
|  |         $sql = "DELETE FROM Inhaltsstoff WHERE id=:id"; | ||||||
|  |         $params[":id"] = $id; | ||||||
|  |         try { | ||||||
|  |             $stmt = $pdo->prepare($sql); | ||||||
|  |             $stmt->execute($params); | ||||||
|  |             return true; | ||||||
|  |         } catch (\PDOException $e) { | ||||||
|  |             echo $sql; | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?> | ||||||
| @@ -1,16 +1,18 @@ | |||||||
| <?php | <?php | ||||||
|  |  | ||||||
| // Programmiert durch Samuel Wolff | // Programmiert durch Samuel Wolff | ||||||
| // Getestet durch: Nicht getestet | // Getestet durch: Samuel Wolff | ||||||
|  |  | ||||||
| namespace kindergartenverwaltung\Model; | namespace ppb\Model; | ||||||
|  |  | ||||||
| use kindergartenverwaltung\Library\Msg; | use ppb\Library\Msg; | ||||||
|  |  | ||||||
|  |  | ||||||
| class KindModel extends Database{ | class KindModel extends Database | ||||||
|  | { | ||||||
|  |  | ||||||
| public function getKind($parentId){ |     public function getKind($parentId) | ||||||
|  |     { | ||||||
|         $pdo = $this->linkDB(); |         $pdo = $this->linkDB(); | ||||||
|  |  | ||||||
|         $params = array(); |         $params = array(); | ||||||
| @@ -19,31 +21,32 @@ public function getKind($parentId){ | |||||||
|  |  | ||||||
|         // Das mitgeben einer Id erlaubt es die Kinder eines bestimmten Benutzerkontos anzeigen zu lassen,  |         // Das mitgeben einer Id erlaubt es die Kinder eines bestimmten Benutzerkontos anzeigen zu lassen,  | ||||||
|         // während das leerlassen alle Kinder ausgibt. |         // während das leerlassen alle Kinder ausgibt. | ||||||
|     id($parentId !== false){ |         if ($parentId !== false) { | ||||||
|         $sql. = " WHERE bid=:id;"; |             $sql .= " WHERE bid=:id;"; | ||||||
|             $params[":id"] = $parentId; |             $params[":id"] = $parentId; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|     try{ |         try { | ||||||
|             $stmt = $pdo->prepare($sql); |             $stmt = $pdo->prepare($sql); | ||||||
|         $stmt->excute($params); |             $stmt->execute($params); | ||||||
|     } |         } catch (\PDOException $e) { | ||||||
|     catch(\PDOException $e){ |  | ||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         $result = $stmt->fetchALL(\PDO::FETCH_ASSOC); |         $result = $stmt->fetchALL(\PDO::FETCH_ASSOC); | ||||||
|  |  | ||||||
|         return $result; |         return $result; | ||||||
| } |     } | ||||||
|  |  | ||||||
| /** |     /** | ||||||
|  |      *  | ||||||
|      * Updated die Daten eines Kindes |      * Updated die Daten eines Kindes | ||||||
|      *  |      *  | ||||||
|      * @param $kindId Id des Kindes |      * @param $kindId Id des Kindes | ||||||
|      * @param $data Json encoded Daten mit den neuen Werten |      * @param $data Json encoded Daten mit den neuen Werten | ||||||
|      */ |      */ | ||||||
| public function updateKind($kindId, $data){ |     public function updateKind($kindId, $data) | ||||||
|  |     { | ||||||
|         $pdo = $this->linkDB(); |         $pdo = $this->linkDB(); | ||||||
|  |  | ||||||
|         $params = array(); |         $params = array(); | ||||||
| @@ -53,67 +56,75 @@ public function updateKind($kindId, $data){ | |||||||
|         // und setzt die Bindparameter |         // und setzt die Bindparameter | ||||||
|         // $index -> Spalte die geupdated wird |         // $index -> Spalte die geupdated wird | ||||||
|         // $value -> neuer Wert |         // $value -> neuer Wert | ||||||
|     foreach($data as $index=>$value){ |         foreach ($data as $index => $value) { | ||||||
|         $sql .= " ".$index." = :".$index; |             $sql .= " " . $index . " = :" . $index; | ||||||
|         $params[":".$index] = $value; |             $params[":" . $index] = $value; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         $sql .= " WHERE id = :kindId;"; |         $sql .= " WHERE id = :kindId;"; | ||||||
|  |  | ||||||
|         $params[":kindId"] = $kindId; |         $params[":kindId"] = $kindId; | ||||||
|  |  | ||||||
|     try{ |         try { | ||||||
|             $stmt = $pdo->prepare($sql); |             $stmt = $pdo->prepare($sql); | ||||||
|         $stmt->excute($params); |             $stmt->execute($params); | ||||||
|     } |         } catch (\PDOException $e) { | ||||||
|     catch(\PDOException $e){ |  | ||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         $result = $stmt->fetchALL(\PDO::FETCH_ASSOC); |         $result = $stmt->fetchALL(\PDO::FETCH_ASSOC); | ||||||
|  |  | ||||||
|         return $result; |         return $result; | ||||||
| } |     } | ||||||
|  |  | ||||||
| /** |     /** | ||||||
|  |      *  | ||||||
|  |      * Fügt ein Kind mit gegebenen Daten in die Datenbank hinzu | ||||||
|  |      *  | ||||||
|      * @param $data Die Daten für das neue Kind |      * @param $data Die Daten für das neue Kind | ||||||
|      */ |      */ | ||||||
| public function addKind($data){ |     public function addKind($data) | ||||||
|  |     { | ||||||
|         $pdo = $this->linkDB(); |         $pdo = $this->linkDB(); | ||||||
|  |  | ||||||
|         $params = array(); |         $params = array(); | ||||||
|  |  | ||||||
|         $sql = "INSERT INTO Kind ("; |         $sql = "INSERT INTO Kind ("; | ||||||
|  |  | ||||||
|     foreach($data as $index=>$value){ |         foreach ($data as $index => $value) { | ||||||
|         $sql .= $index.", "; |             $sql .= $index . ", "; | ||||||
|         $params[":"+$index] = $index; |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|     $sql = substr($sql, 0, strlen($sql)-2).") VALUES ("; |         $sql = substr($sql, 0, strlen($sql) - 2) . ") VALUES ("; | ||||||
|  |  | ||||||
|     foreach($data as $value){ |         foreach ($data as $value) { | ||||||
|         $sql .= ":".$value." ,"; |             $sql .= ":" . $value . " ,"; | ||||||
|         $params[":"+$value] = $value; |             $params[":" . $value] = $value; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|     $sql = substr($sql, 0, strlen($sql)-2).");"; |         $sql = substr($sql, 0, strlen($sql) - 2) . ");"; | ||||||
|  |  | ||||||
|     try{ |         try { | ||||||
|             $stmt = $pdo->prepare($sql); |             $stmt = $pdo->prepare($sql); | ||||||
|         $stmt->excute($params); |             $stmt->execute($params); | ||||||
|     } |         } catch (\PDOException $e) { | ||||||
|     catch(\PDOException $e){ |  | ||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         $result = $stmt->fetchALL(\PDO::FETCH_ASSOC); |         $result = $stmt->fetchALL(\PDO::FETCH_ASSOC); | ||||||
|  |  | ||||||
|         return $result; |         return $result; | ||||||
| } |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
| public function deleteKind($kindId){ |      *  | ||||||
|  |      * Löscht ein Kind mit einer gegebenen Id aus der Datenbank | ||||||
|  |      *  | ||||||
|  |      * @param $kindId Die Id des zu löschenden Kindes | ||||||
|  |      *  | ||||||
|  |      */ | ||||||
|  |     public function deleteKind($kindId) | ||||||
|  |     { | ||||||
|         $pdo = $this->linkDB(); |         $pdo = $this->linkDB(); | ||||||
|  |  | ||||||
|         $params = array(); |         $params = array(); | ||||||
| @@ -122,18 +133,17 @@ public function deleteKind($kindId){ | |||||||
|  |  | ||||||
|         $params[":id"] = $kindId; |         $params[":id"] = $kindId; | ||||||
|  |  | ||||||
|     try{ |         try { | ||||||
|             $stmt = $pdo->prepare($sql); |             $stmt = $pdo->prepare($sql); | ||||||
|         $stmt->excute($params); |             $stmt->execute($params); | ||||||
|     } |         } catch (\PDOException $e) { | ||||||
|     catch(\PDOException $e){ |  | ||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         $result = $stmt->fetchALL(\PDO::FETCH_ASSOC); |         $result = $stmt->fetchALL(\PDO::FETCH_ASSOC); | ||||||
|  |  | ||||||
|         return $result; |         return $result; | ||||||
| } |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										69
									
								
								Model/TagesplanModel.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										69
									
								
								Model/TagesplanModel.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,69 @@ | |||||||
|  | <?php | ||||||
|  |  | ||||||
|  | //Programmiert von: Max Heer, Getestet von: Samuel Wolff | ||||||
|  |  | ||||||
|  | namespace ppb\Model; | ||||||
|  |  | ||||||
|  | use ppb\Library\Msg; | ||||||
|  |  | ||||||
|  | class TagesplanModel extends Database | ||||||
|  | { | ||||||
|  |  | ||||||
|  |     public function getTagesplan() | ||||||
|  |     { | ||||||
|  |         $pdo = $this->linkDB(); | ||||||
|  |         $sql = "SELECT * FROM Tagesplan"; | ||||||
|  |         try { | ||||||
|  |             $stmt = $pdo->prepare($sql); | ||||||
|  |             $stmt->execute(); | ||||||
|  |         } catch (\PDOException $e) { | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  |         $result = $stmt->fetchAll(\PDO::FETCH_ASSOC); | ||||||
|  |  | ||||||
|  |         return $result; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public function insertTagesplan($data) | ||||||
|  |     { | ||||||
|  |         $pdo = $this->linkDB(); | ||||||
|  |         $params = array(); | ||||||
|  |         $sql = "INSERT INTO Tagesplan ("; | ||||||
|  |         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 (\PDOException $e) { | ||||||
|  |             echo $sql; | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public function deleteTagesplan($id) | ||||||
|  |     { | ||||||
|  |         $pdo = $this->linkDB(); | ||||||
|  |         $params = array(); | ||||||
|  |         $sql = "DELETE FROM Tagesplan WHERE id=:id"; | ||||||
|  |         $params[":id"] = $id; | ||||||
|  |         try { | ||||||
|  |             $stmt = $pdo->prepare($sql); | ||||||
|  |             $stmt->execute($params); | ||||||
|  |             return true; | ||||||
|  |         } catch (\PDOException $e) { | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | ?> | ||||||
| @@ -1,45 +1,74 @@ | |||||||
| <?php | <?php | ||||||
|  |  | ||||||
| namespace kinderverwaltung\Model; | namespace ppb\Model; | ||||||
|  |  | ||||||
| use kinderverwaltung\Library\Msg; | //Programmiert von Stefan Groß  | ||||||
| use ppb\Model\Database; | //getestet von Samuel Wolff | ||||||
|  |  | ||||||
| class IstTeilModel extends Database{ | class istTeilModel extends Database | ||||||
|  | { | ||||||
|  |  | ||||||
|     public function getBestellung(){ |     public function selectIstTeil() | ||||||
|         $pdo = $this -> linkDB(); |     { | ||||||
|  |         $pdo = $this->linkDB(); | ||||||
|  |  | ||||||
|         $sql = "SELECT bid FROM istTeil"; |         $sql = "SELECT * FROM istTeil"; | ||||||
|  |  | ||||||
|         try { |         try { | ||||||
|             $stmt = $pdo->prepare($sql); |             $stmt = $pdo->prepare($sql); | ||||||
|     }catch (\PDOException $e){ |             $stmt->execute(); | ||||||
|         //nur zum Testen: |         } catch (\PDOException $e) { | ||||||
|         //new Msg(true,null,$e); |  | ||||||
|         //echo $e; |  | ||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
|     return $stmt->fetchAll(\PDO::FETCH_ASSOC); |         $results = $stmt->fetchAll(\PDO::FETCH_ASSOC); | ||||||
|  |  | ||||||
|  |         foreach ($results as $key => $value) { | ||||||
|  |             $results[$key]["bid"] += 0; | ||||||
|  |             $results[$key]["gid"] += 0; | ||||||
|  |             $results[$key]["id"] += 0; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         return $results; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     public function InsertIstTeil($data){ |     public function insertIstTeil($data) | ||||||
|         $pdo = $this -> linkDB(); |     { | ||||||
|  |         $pdo = $this->linkDB(); | ||||||
|  |  | ||||||
|         $sql = "INSERT INTO istTeil(bid, gid)"; |         $params = array(); | ||||||
|  |  | ||||||
|  |         $sql = "INSERT INTO istTeil (bid, gid) VALUES (:bid, :gid)"; | ||||||
|  |  | ||||||
|  |         foreach ($data as $key => $value) { | ||||||
|  |             $params[":" . $key] = $value; | ||||||
|  |         } | ||||||
|  |  | ||||||
|         try { |         try { | ||||||
|             $stmt = $pdo->prepare($sql); |             $stmt = $pdo->prepare($sql); | ||||||
|         }catch (\PDOException $e){ |             $stmt->execute($params); | ||||||
|             //nur zum Testen: |         } catch (\PDOException $e) { | ||||||
|             //new Msg(true,null,$e); |  | ||||||
|             //echo $e; |  | ||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
|         return $stmt->fetchAll(\PDO::FETCH_ASSOC); |         return true; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public function deleteIstTeil($id) | ||||||
|  |     { | ||||||
|  |         $pdo = $this->linkDB(); | ||||||
|  |  | ||||||
|  |         $params = array(); | ||||||
|  |  | ||||||
|  |         $sql = "DELETE FROM istTeil WHERE id = :id"; | ||||||
|  |  | ||||||
|  |         $params[":id"] = $id; | ||||||
|  |  | ||||||
|  |         try { | ||||||
|  |             $stmt = $pdo->prepare($sql); | ||||||
|  |             $stmt->execute($params); | ||||||
|  |         } catch (\PDOException $e) { | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  |         return true; | ||||||
|     } |     } | ||||||
| } | } | ||||||
| ?> | ?> | ||||||
		Reference in New Issue
	
	Block a user