Testing #7

Merged
PBG2H22AWO merged 1 commits from Testing into main 2024-01-14 18:32:00 +01:00
7 changed files with 61 additions and 38 deletions

View File

@ -1,7 +1,7 @@
<?php <?php
// Programmiert durch Samuel Wolff // Programmiert durch Samuel Wolff
// Getestet durch: Nicht getestet // Getestet durch: Samuel Wolff
namespace ppb\Controller; namespace ppb\Controller;

View File

@ -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;

View File

@ -1,23 +1,37 @@
<?php <?php
//Programmiert von: Max Heer, Getestet von: //Programmiert von: Max Heer, Getestet von: Samuel Wolff
namespace VPR_Schnittstelle\Controller; namespace ppb\Controller;
use VPR_Schnittstelle\Libary\Msg; use ppb\Libary\Msg;
use VPR_Schnittstelle\Model\TagesplanModel; use ppb\Model\TagesplanModel;
public function getTagesplan(){ class TagesplanController
$result=$this->db->getTagesplan(); {
private $db;
public function __construct()
{
$this->db = new TagesplanModel();
}
public function getTagesplan()
{
$result = $this->db->getTagesplan();
return json_encode($result); return json_encode($result);
} }
public function insertTagesplan($data){ public function writeTagesplan($data)
$result=$this->db->insertTagesplan($data); {
$result = $this->db->insertTagesplan($data);
return json_encode($result); return json_encode($result);
} }
public function deleteTagesplan($id){ public function deleteTagesplan($id)
$result=$this->db->deleteTagesplan($id); {
$result = $this->db->deleteTagesplan($id);
return json_encode($result); return json_encode($result);
} }
}
?> ?>

View File

@ -1,5 +1,5 @@
<?php <?php
// Erstellt durch Stefan Groß - Nicht getestet // Erstellt durch Stefan Groß - Getestet von Samuel Wolff
namespace ppb\Controller; namespace ppb\Controller;
use ppb\Model\IstTeilModel; use ppb\Model\IstTeilModel;

View File

@ -1,5 +1,7 @@
<?php <?php
//Programmiert von: Max Heer, Getestet von: Samuel Wolff
namespace ppb\Model; namespace ppb\Model;
use ppb\Library\Msg; use ppb\Library\Msg;

View File

@ -1,4 +1,5 @@
<?php <?php
// Programmiert von Max Heer
// Getestet von Samuel Wolff // Getestet von Samuel Wolff
namespace ppb\Model; namespace ppb\Model;

View File

@ -1,18 +1,22 @@
<?php <?php
//Programmiert von: Max Heer, Getestet von: //Programmiert von: Max Heer, Getestet von: Samuel Wolff
namespace VPR_Schnittstelle\EnthaeltModel; namespace ppb\Model;
use VPR_Schnittstelle\Library\Msg;
public function getTagesplan(){ use ppb\Library\Msg;
$pdo=$this->linkDB();
class TagesplanModel extends Database
{
public function getTagesplan()
{
$pdo = $this->linkDB();
$sql = "SELECT * FROM Tagesplan"; $sql = "SELECT * FROM Tagesplan";
try{ try {
$stmt = $pdo->prepare($sql); $stmt = $pdo->prepare($sql);
$stmt->execute(); $stmt->execute();
} } catch (\PDOException $e) {
catch(\PDOExeption $e){
return false; return false;
} }
$result = $stmt->fetchAll(\PDO::FETCH_ASSOC); $result = $stmt->fetchAll(\PDO::FETCH_ASSOC);
@ -20,44 +24,46 @@
return $result; return $result;
} }
public function insertTagesplan($data){ public function insertTagesplan($data)
$pdo=$this->linkDB(); {
$pdo = $this->linkDB();
$params = array(); $params = array();
$sql = "INSERT INTO Tagesplan ("; $sql = "INSERT INTO Tagesplan (";
foreach($data as $index=>$value){ foreach ($data as $index => $value) {
$sql .= "".$index.","; $sql .= "" . $index . ",";
} }
$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) . ");";
try{ try {
$stmt = $pdo->prepare($sql); $stmt = $pdo->prepare($sql);
$stmt->execute($params); $stmt->execute($params);
return true; return true;
} } catch (\PDOException $e) {
catch(\PDOExeption $e){ echo $sql;
return false; return false;
} }
} }
public function delteTagesplan($id){ public function deleteTagesplan($id)
$pdo=$this->linkDB(); {
$pdo = $this->linkDB();
$params = array(); $params = array();
$sql = "DELETE FROM Tagesplan WHERE id=:id"; $sql = "DELETE FROM Tagesplan WHERE id=:id";
$params[":id"] = $id; $params[":id"] = $id;
try{ try {
$stmt = $pdo->prepare($sql); $stmt = $pdo->prepare($sql);
$stmt->execute($params); $stmt->execute($params);
return true; return true;
} } catch (\PDOException $e) {
catch(\PDOExeption $e){
return false; return false;
} }
} }
}
?> ?>