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 <?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
{
private $db;
public function __construct()
{
$this->db = new TagesplanModel();
}
public function getTagesplan()
{
$result = $this->db->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;
class TagesplanModel extends Database
{
public function getTagesplan()
{
$pdo = $this->linkDB(); $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,7 +24,8 @@
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 (";
@ -30,7 +35,7 @@
$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;
} }
@ -40,13 +45,14 @@
$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";
@ -55,9 +61,9 @@
$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;
} }
} }
}
?> ?>