Test waren doch noch nicht done *smileyface*

This commit is contained in:
Samuel Wolff 2024-01-14 18:30:05 +01:00
parent f0caeb3cfc
commit d4c11ef611
7 changed files with 61 additions and 38 deletions

View File

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

View File

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

View File

@ -1,23 +1,37 @@
<?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 VPR_Schnittstelle\Model\TagesplanModel;
use ppb\Libary\Msg;
use ppb\Model\TagesplanModel;
public function getTagesplan(){
$result=$this->db->getTagesplan();
class TagesplanController
{
private $db;
public function __construct()
{
$this->db = new TagesplanModel();
}
public function getTagesplan()
{
$result = $this->db->getTagesplan();
return json_encode($result);
}
public function insertTagesplan($data){
$result=$this->db->insertTagesplan($data);
public function writeTagesplan($data)
{
$result = $this->db->insertTagesplan($data);
return json_encode($result);
}
public function deleteTagesplan($id){
$result=$this->db->deleteTagesplan($id);
public function deleteTagesplan($id)
{
$result = $this->db->deleteTagesplan($id);
return json_encode($result);
}
}
?>

View File

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

View File

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

View File

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

View File

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