2023-12-06 08:33:25 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// Programmiert durch Samuel Wolff
|
|
|
|
// Getestet durch: Nicht getestet
|
|
|
|
|
2023-12-14 16:59:16 +01:00
|
|
|
namespace ppb\Controller;
|
2023-12-06 08:33:25 +01:00
|
|
|
|
2023-12-14 16:59:16 +01:00
|
|
|
use ppb\Library\Msg;
|
|
|
|
use ppb\Model\BenutzerModel;
|
2023-12-06 08:33:25 +01:00
|
|
|
|
|
|
|
class BenutzerModel extends Database{
|
|
|
|
|
2023-12-11 15:34:55 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Updated einen Benutzer
|
|
|
|
*
|
|
|
|
* @param $elternId Die Id des Elternaccounts
|
|
|
|
* @param $data Die gegebenen Daten
|
|
|
|
*
|
|
|
|
*/
|
2023-12-06 08:33:25 +01:00
|
|
|
public function updateBenutzer($elternId, $data){
|
|
|
|
$pdo = $this->linkDB();
|
|
|
|
|
|
|
|
$params = array();
|
|
|
|
|
|
|
|
$sql = "UPDATE Benutzer SET"
|
|
|
|
|
|
|
|
foreach($data as $index=>$value){
|
|
|
|
$sql .= " ".$index." = :".$index;
|
|
|
|
$params[":".$index] = $value;
|
|
|
|
}
|
|
|
|
|
|
|
|
$sql .= " WHERE id = :benutzerId;";
|
|
|
|
|
|
|
|
$params[":benutzerId"] = $kindId;
|
|
|
|
|
|
|
|
try{
|
|
|
|
$stmt = $pdo->prepare($sql);
|
|
|
|
$stmt->excute($params);
|
|
|
|
}
|
|
|
|
catch(\PDOException $e){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$result = $stmt->fetchALL(\PDO::FETCH_ASSOC);
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-12-11 15:34:55 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Fügt einen neuen Benutzer in der Datenbank hinzu
|
|
|
|
*
|
|
|
|
* @param $data Die gegebenen Daten
|
|
|
|
*
|
|
|
|
*/
|
2023-12-06 08:33:25 +01:00
|
|
|
public function insertBenutzer($data){
|
|
|
|
$pdo = $this->linkDB();
|
|
|
|
|
|
|
|
$params = array();
|
|
|
|
|
|
|
|
$sql = "INSERT INTO Benutzer (";
|
|
|
|
|
|
|
|
foreach($data as $index=>$value){
|
|
|
|
$sql .= $index.", ";
|
|
|
|
$params[":"+$index] = $index;
|
|
|
|
}
|
|
|
|
|
|
|
|
$sql = substr($sql, 0, strlen($sql)-2).") VALUES (";
|
|
|
|
|
|
|
|
foreach($data as $value){
|
|
|
|
$sql .= ":".$value." ,";
|
|
|
|
$params[":"+$value] = $value;
|
|
|
|
}
|
|
|
|
|
|
|
|
$sql = substr($sql, 0, strlen($sql)-2).");";
|
|
|
|
|
|
|
|
try{
|
|
|
|
$stmt = $pdo->prepare($sql);
|
|
|
|
$stmt->excute($params);
|
|
|
|
}
|
|
|
|
catch(\PDOException $e){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$result = $stmt->fetchALL(\PDO::FETCH_ASSOC);
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|