Tests bis zu Gericht Model
This commit is contained in:
		| @@ -1,44 +1,50 @@ | |||||||
| <?php | <?php | ||||||
| //Programmierung: Sven Alteköster 100% | //Programmierung: Sven Alteköster 100% | ||||||
| //Getestet durch:  | //Getestet durch: Samuel Wolff | ||||||
|  |  | ||||||
| namespace ppb\Controller; | namespace ppb\Controller; | ||||||
|  |  | ||||||
| use ppb\Library\Msg; | use ppb\Library\Msg; | ||||||
| use ppb\Model\BestellungModel; | use ppb\Model\BestellungModel; | ||||||
|  |  | ||||||
| class BestellungController { | class BestellungController | ||||||
|  | { | ||||||
|  |  | ||||||
|   private $db; |   private $db; | ||||||
|  |  | ||||||
| 	public function __construct() {	   |   public function __construct() | ||||||
|  |   { | ||||||
|     $this->db = new BestellungModel(); |     $this->db = new BestellungModel(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|     public function getBestellung($id=false) { |   public function getBestellung($id = false) | ||||||
|         $result=$this->db->selectBestellung($id); |   { | ||||||
|         if($id !== false){ |     $result = $this->db->selectBestellung($id); | ||||||
|           if($result) |     if ($id !== false) { | ||||||
|             $result=$result[0]; |       if ($result) | ||||||
|  |         $result = $result[0]; | ||||||
|       else |       else | ||||||
|             $result=false; |         $result = false; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     return json_encode($result); |     return json_encode($result); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|     public function writeBestellung($data){ |   public function writeBestellung($data) | ||||||
|       $result=$this->db->insertGericht($data); |   { | ||||||
|  |     $result = $this->db->insertBestellung($data); | ||||||
|     return json_encode($result); |     return json_encode($result); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|     public function updateBestellung($id, $data){ |   public function updateBestellung($id, $data) | ||||||
|       $result=$this->db->updateBestellung($id, $data); |   { | ||||||
|  |     $result = $this->db->updateBestellung($id, $data); | ||||||
|     return json_encode($result); |     return json_encode($result); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|     public function deleteBestellung($id){ |   public function deleteBestellung($id) | ||||||
|       $result=$this->db->deleteBestellung($id); |   { | ||||||
|  |     $result = $this->db->deleteBestellung($id); | ||||||
|     return json_encode($result); |     return json_encode($result); | ||||||
|   } |   } | ||||||
| } | } | ||||||
| @@ -1,5 +1,5 @@ | |||||||
| <?php | <?php | ||||||
| //Programmiert von: Max Heer, Getestet von:  | //Programmiert von: Max Heer, Getestet von: Samuel Wolff | ||||||
|  |  | ||||||
| namespace ppb\Controller; | namespace ppb\Controller; | ||||||
|  |  | ||||||
| @@ -16,13 +16,13 @@ class EnthaeltController | |||||||
|         $this->db = new EnthaeltModel(); |         $this->db = new EnthaeltModel(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function getInhaltsstoffe($gerichtId) |     public function getEnthaelt($gerichtId) | ||||||
|     { |     { | ||||||
|         $result = $this->db->getEnthaelt($gerichtId); |         $result = $this->db->getEnthaelt($gerichtId); | ||||||
|         return json_encode($result); |         return json_encode($result); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function insertEnthaelt($data) |     public function writeEnthaelt($data) | ||||||
|     { |     { | ||||||
|         $result = $this->db->insertEnthaelt($data); |         $result = $this->db->insertEnthaelt($data); | ||||||
|         return json_encode($result); |         return json_encode($result); | ||||||
|   | |||||||
| @@ -36,12 +36,14 @@ class EnthaeltModel extends Database | |||||||
|         $sql = substr($sql, 0, strlen($sql) - 1) . ") VALUES ("; |         $sql = substr($sql, 0, strlen($sql) - 1) . ") VALUES ("; | ||||||
|  |  | ||||||
|         foreach ($data as $index => $value) { |         foreach ($data as $index => $value) { | ||||||
|             $sql .= "':" . $index . "',"; |             $sql .= ":" . $index . ","; | ||||||
|             $params[":" . $index] = $value; |             $params[":" . $index] = $value; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         $sql = substr($sql, 0, strlen($sql) - 1) . ");"; |         $sql = substr($sql, 0, strlen($sql) - 1) . ");"; | ||||||
|  |  | ||||||
|  |         echo $sql; | ||||||
|  |  | ||||||
|         try { |         try { | ||||||
|             $stmt = $pdo->prepare($sql); |             $stmt = $pdo->prepare($sql); | ||||||
|             $stmt->execute($params); |             $stmt->execute($params); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user