Merge pull request 'Testing' (#7) from Testing into main

Reviewed-on: #7
This commit is contained in:
Samuel Wolff 2024-01-14 18:31:59 +01:00
commit 3f5bd9b1bc
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(){
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){
public function writeTagesplan($data)
{
$result = $this->db->insertTagesplan($data);
return json_encode($result);
}
public function 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(){
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(\PDOExeption $e){
} catch (\PDOException $e) {
return false;
}
$result = $stmt->fetchAll(\PDO::FETCH_ASSOC);
@ -20,7 +24,8 @@
return $result;
}
public function insertTagesplan($data){
public function insertTagesplan($data)
{
$pdo = $this->linkDB();
$params = array();
$sql = "INSERT INTO Tagesplan (";
@ -30,7 +35,7 @@
$sql = substr($sql, 0, strlen($sql) - 1) . ") VALUES (";
foreach ($data as $index => $value) {
$sql .= "':".$index."',";
$sql .= ":" . $index . ",";
$params[":" . $index] = $value;
}
@ -40,13 +45,14 @@
$stmt = $pdo->prepare($sql);
$stmt->execute($params);
return true;
}
catch(\PDOExeption $e){
} catch (\PDOException $e) {
echo $sql;
return false;
}
}
public function delteTagesplan($id){
public function deleteTagesplan($id)
{
$pdo = $this->linkDB();
$params = array();
$sql = "DELETE FROM Tagesplan WHERE id=:id";
@ -55,9 +61,9 @@
$stmt = $pdo->prepare($sql);
$stmt->execute($params);
return true;
}
catch(\PDOExeption $e){
} catch (\PDOException $e) {
return false;
}
}
}
?>