more fixes

This commit is contained in:
Samuel Wolff 2023-12-18 08:19:27 +01:00
parent c598e48006
commit 621e25ee86
3 changed files with 50 additions and 49 deletions

View File

@ -1,10 +1,10 @@
<?php <?php
//Programmiert von: Max Heer, Getestet von: //Programmiert von: Max Heer, Getestet von:
namespace kindergartenverwaltung\Controller; namespace ppb\Controller;
use kindergartenverwaltung\Libary\Msg; use ppb\Libary\Msg;
use kindergartenverwaltung\Model\EnthaeltModel; use ppb\Model\EnthaeltModel;
class EnthaeltController class EnthaeltController
{ {

View File

@ -3,7 +3,7 @@
// Programmiert durch Samuel Wolff // Programmiert durch Samuel Wolff
// Getestet durch: Nicht getestet // Getestet durch: Nicht getestet
namespace ppb\Controller; namespace ppb\Model;
use ppb\Library\Msg; use ppb\Library\Msg;
@ -38,7 +38,7 @@ class BenutzerModel extends Database
try { try {
$stmt = $pdo->prepare($sql); $stmt = $pdo->prepare($sql);
$stmt->excute($params); $stmt->execute($params);
} catch (\PDOException $e) { } catch (\PDOException $e) {
return false; return false;
} }
@ -80,7 +80,7 @@ class BenutzerModel extends Database
try { try {
$stmt = $pdo->prepare($sql); $stmt = $pdo->prepare($sql);
$stmt->excute($params); $stmt->execute($params);
} catch (\PDOException $e) { } catch (\PDOException $e) {
return false; return false;
} }

View File

@ -1,52 +1,53 @@
<?php <?php
namespace kindergartenverwaltung\EnthaeltModel; namespace ppb\EnthaeltModel;
use kindergartenverwaltung\Library\Msg; use ppb\Library\Msg;
class EnthaeltModel extends Database{ class EnthaeltModel extends Database
{
public function getEnthaelt($gerichtId){ public function getEnthaelt($gerichtId)
$pdo=$this->linkDB(); {
$params = array(); $pdo = $this->linkDB();
$sql = "SELECT * FROM Enthaelt WHERE gid = :gerichtId;"; $params = array();
$params[":gerichtId"] = gerichtId; $sql = "SELECT * FROM Enthaelt WHERE gid = :gerichtId;";
try{ $params[":gerichtId"] = $gerichtId;
$stmt = $pdo->prepare($sql); try {
$stmt->execute($params); $stmt = $pdo->prepare($sql);
} $stmt->execute($params);
catch(\PDOExeption $e){ } catch (\PDOException $e) {
return false; return false;
} }
$result = $stmt->fetchAll(\PDO::FETCH_ASSOC); $result = $stmt->fetchAll(\PDO::FETCH_ASSOC);
return $result; return $result;
}
public function insertEnthaelt($data)
{
$pdo = $this->linkDB();
$params = array();
$sql = "INSERT INTO Enthaelt (";
foreach ($data as $index => $value) {
$sql .= "" . $index . ",";
}
$sql = substr($sql, 0, strlen($sql) - 1) . ") VALUES (";
foreach ($data as $index => $value) {
$sql .= "':" . $index . "',";
$params[":" . $index] = $value;
} }
public function insertEnthaelt($data){ $sql = substr($sql, 0, strlen($sql) - 1) . ");";
$pdo=$this->linkDB();
$params = array();
$sql = "INSERT INTO Enthaelt (";
foreach($data as $index=>$value){ try {
$sql .= "".$index.","; $stmt = $pdo->prepare($sql);
} $stmt->execute($params);
$sql = substr($sql,0,strlen($sql)-1).") VALUES ("; return true;
} catch (\PDOException $e) {
foreach($data as $index=>$value){ return false;
$sql .= "':".$index."',";
$params[":".$index] = $value;
}
$sql = substr($sql,0,strlen($sql)-1).");";
try{
$stmt = $pdo->prepare($sql);
$stmt->execute($params);
return true;
}
catch(\PDOExeption $e){
return false;
}
} }
} }
}
?> ?>