Compare commits
14 Commits
max
...
7b55e50029
Author | SHA1 | Date | |
---|---|---|---|
7b55e50029 | |||
7bb6d00eb1 | |||
23df80f0db | |||
5765d49e01 | |||
c28a3eb452 | |||
9f7060d202 | |||
a915732afd | |||
05dcaf2555 | |||
e190b5bb8d | |||
16be7cf3dc | |||
cab0d36555 | |||
62df0fcaf0 | |||
6e52a22691 | |||
![]() |
ac22e2fca4 |
@@ -3,10 +3,10 @@
|
||||
// Programmiert durch Samuel Wolff
|
||||
// Getestet durch: Nicht getestet
|
||||
|
||||
namespace kindergartenverwaltung\Controller;
|
||||
namespace ppb\Controller;
|
||||
|
||||
use kindergartenverwaltung\Library\Msg;
|
||||
use kindergartenverwaltung\Model\BenutzerModel;
|
||||
use ppb\Library\Msg;
|
||||
use ppb\Model\BenutzerModel;
|
||||
|
||||
class BenutzerController{
|
||||
|
||||
@@ -16,6 +16,7 @@ class BenutzerController{
|
||||
$this->db = new BenutzerModel();
|
||||
}
|
||||
|
||||
// Updated einen Benutzer
|
||||
public function updateBenutzer($elternId, $data){
|
||||
|
||||
$result = $this->db->updateBenutzer($benutzerId, $data);
|
||||
@@ -24,6 +25,7 @@ class BenutzerController{
|
||||
|
||||
}
|
||||
|
||||
// Fügt einen Benutzer in die Datenbank hinzu
|
||||
public function insertBenutzer($data){
|
||||
$result = $this->db->insertBenutzer($data)
|
||||
|
||||
|
44
Controller/BestellungController.php
Normal file
44
Controller/BestellungController.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
//Programmierung: Sven Alteköster 100%
|
||||
//Getestet durch: Sven Alteköster 100%
|
||||
|
||||
namespace ppb\Controller;
|
||||
|
||||
use ppb\Library\Msg;
|
||||
use ppb\Model\BestellungModel;
|
||||
|
||||
class BestellungController {
|
||||
|
||||
private $db;
|
||||
|
||||
public function __construct() {
|
||||
$this->db = new BestellungModel();
|
||||
}
|
||||
|
||||
public function getBestellung($id=false) {
|
||||
$result=$this->db->selectBestellung($id);
|
||||
if($id !== false){
|
||||
if($result)
|
||||
$result=$result[0];
|
||||
else
|
||||
$result=false;
|
||||
}
|
||||
|
||||
return json_encode($result);
|
||||
}
|
||||
|
||||
public function writeBestellung($data){
|
||||
$result=$this->db->insertGericht($data);
|
||||
return json_encode($result);
|
||||
}
|
||||
|
||||
public function updateBestellung($id, $data){
|
||||
$result=$this->db->updateBestellung($id, $data);
|
||||
return json_encode($result);
|
||||
}
|
||||
|
||||
public function deleteBestellung($id){
|
||||
$result=$this->db->deleteBestellung($id);
|
||||
return json_encode($result);
|
||||
}
|
||||
}
|
44
Controller/GerichtController.php
Normal file
44
Controller/GerichtController.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
//Programmierung: Sven Alteköster 100%
|
||||
//Getestet durch: Sven Alteköster 100%
|
||||
|
||||
namespace ppb\Controller;
|
||||
|
||||
use ppb\Library\Msg;
|
||||
use ppb\Model\GerichtModel;
|
||||
|
||||
class GerichtController {
|
||||
|
||||
private $db;
|
||||
|
||||
public function __construct() {
|
||||
$this->db = new GerichtModel();
|
||||
}
|
||||
|
||||
public function getGericht($id=false) {
|
||||
$result=$this->db->selectGericht($id);
|
||||
if($id !== false){
|
||||
if($result)
|
||||
$result=$result[0];
|
||||
else
|
||||
$result=false;
|
||||
}
|
||||
|
||||
return json_encode($result);
|
||||
}
|
||||
|
||||
public function writeGericht($data){
|
||||
$result=$this->db->insertGericht($data);
|
||||
return json_encode($result);
|
||||
}
|
||||
|
||||
public function updateGericht($id, $data){
|
||||
$result=$this->db->updateGericht($id, $data);
|
||||
return json_encode($result);
|
||||
}
|
||||
|
||||
public function deleteGericht($id){
|
||||
$result=$this->db->deleteGericht($id);
|
||||
return json_encode($result);
|
||||
}
|
||||
}
|
@@ -3,10 +3,10 @@
|
||||
// Programmiert durch Samuel Wolff
|
||||
// Getestet durch: Nicht getestet
|
||||
|
||||
namespace kindergartenverwaltung\Controller;
|
||||
namespace ppb\Controller;
|
||||
|
||||
use kindergartenverwaltung\Library\Msg;
|
||||
use kindergartenverwaltung\Model\KindModel;
|
||||
use ppb\Library\Msg;
|
||||
use ppb\Model\KindModel;
|
||||
|
||||
class KindController{
|
||||
|
||||
@@ -24,18 +24,21 @@ class KindController{
|
||||
return json_encode($result);
|
||||
}
|
||||
|
||||
// Updated ein Kind
|
||||
public function updateKind($kindId, $data){
|
||||
$result = $this->db->updateKind($kindId, $data);
|
||||
|
||||
return json_encode($result);
|
||||
}
|
||||
|
||||
// Fügt ein Kind hinzu
|
||||
public function addKind($data){
|
||||
$result = $this->db->addKind($data);
|
||||
|
||||
return json_encode($data);
|
||||
}
|
||||
|
||||
// Löscht ein Kind
|
||||
public function deleteKind($kindId){
|
||||
$result = $this->db->deleteKind($kindId);
|
||||
|
||||
|
@@ -3,13 +3,22 @@
|
||||
// Programmiert durch Samuel Wolff
|
||||
// Getestet durch: Nicht getestet
|
||||
|
||||
namespace kindergartenverwaltung\Controller;
|
||||
namespace ppb\Controller;
|
||||
|
||||
use kindergartenverwaltung\Library\Msg;
|
||||
use kindergartenverwaltung\Model\BenutzerModel;
|
||||
use ppb\Library\Msg;
|
||||
use ppb\Model\BenutzerModel;
|
||||
|
||||
class BenutzerModel extends Database{
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Updated einen Benutzer
|
||||
*
|
||||
* @param $elternId Die Id des Elternaccounts
|
||||
* @param $data Die gegebenen Daten
|
||||
*
|
||||
*/
|
||||
public function updateBenutzer($elternId, $data){
|
||||
$pdo = $this->linkDB();
|
||||
|
||||
@@ -40,6 +49,13 @@ class BenutzerModel extends Database{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Fügt einen neuen Benutzer in der Datenbank hinzu
|
||||
*
|
||||
* @param $data Die gegebenen Daten
|
||||
*
|
||||
*/
|
||||
public function insertBenutzer($data){
|
||||
$pdo = $this->linkDB();
|
||||
|
||||
|
105
Model/BestellungModel.php
Normal file
105
Model/BestellungModel.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
//Programmierung: Sven Alteköster 100%
|
||||
//Getestet durch: Sven Alteköster 100%
|
||||
|
||||
namespace ppb\Model;
|
||||
|
||||
use ppb\Library\Msg;
|
||||
|
||||
class BestellungModel extends Database {
|
||||
|
||||
/**
|
||||
* Sucht die Bestellung in der Datenbank und gibt diese im json-Format zurück.
|
||||
* @param $id gibt die id, des Benutzerkontos an, über den die Bestellung getätigt wurde. Wenn keine id angegeben wird, werden alle Einträge ausgegeben
|
||||
*/
|
||||
public function selectBestellung($id = false) {
|
||||
$pdo = $this -> linkDB();
|
||||
$sql = "SELECT Bestellung.id, Bestellung.istBezahlt, Bestellung.bestelldatum, Bestellung.gesamtpreis, Bestellung.kid FROM Bestellung";
|
||||
$params = array();
|
||||
//Ist eine id angegeben wird der Datensatz in der Datenbank gesucht
|
||||
if($id !== false){
|
||||
$sql .= " INNER JOIN Kind k ON k.id = kid INNER JOIN Benutzerkonto b ON b.id = bid";
|
||||
$sql .= " WHERE bid = :bid";
|
||||
$params["bid"] = $id;
|
||||
}
|
||||
|
||||
//Ausführen des SQL befehls
|
||||
try {
|
||||
$stmt = $pdo -> prepare($sql);
|
||||
$stmt -> execute($params);
|
||||
}
|
||||
catch(\PDOException $e) {
|
||||
echo $e;
|
||||
return false;
|
||||
}
|
||||
$result = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
|
||||
//Die Datensätze werden nummeriert
|
||||
foreach($result as $key=>$row){
|
||||
$result[$key]["id"]+=0;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fügt ein Bestellung in die Datenbank ein.
|
||||
* @param $data gibt die Attribute des Datensatzes an.
|
||||
*/
|
||||
public function insertBestellung($data) {
|
||||
$pdo = $this -> linkDB();
|
||||
$sql = "INSERT INTO Bestellung (" . implode(",", array_keys($data)) . ") VALUES(:" . implode(",:", array_keys($data)) . ")";
|
||||
|
||||
try{
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$result = $stmt->execute($data);
|
||||
}catch (\PDOExpecion $e) {
|
||||
echo $e;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updatet einen Datensatz in der Bestellung Tabelle.
|
||||
* @param $id des Datensatzes
|
||||
* @param $data neue Parameter des Datensatzes
|
||||
*/
|
||||
public function updateBestellung($id, $data){
|
||||
$pdo = $this->linkDB();
|
||||
$sql = "UPDATE Bestellung SET ";
|
||||
//Fügt alle Parameter und einen Platzhalter in den SQL Befehl ein
|
||||
foreach (array_keys($data) as $key){
|
||||
$sql .= $key . " = :" . $key. ",";
|
||||
}
|
||||
$sql = substr_replace($sql, "", -1) . " WHERE id = :id";
|
||||
$data["id"] = $id;
|
||||
try{
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$result = $stmt->execute($data);
|
||||
}catch (\PDOExpection $e){
|
||||
echo $e;
|
||||
return false;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Löscht ein Bestellung aus der Tabelle
|
||||
* @param $id des zu löschenden Bestellung
|
||||
*/
|
||||
public function deleteBestellung($id){
|
||||
$pdo = $this->linkDB();
|
||||
$sql = "DELETE FROM Bestellung WHERE id = :id";
|
||||
$params = array();
|
||||
$params[":id"] = $id;
|
||||
try{
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$result = $stmt->execute($params);
|
||||
}catch (\PDOExpection $e){
|
||||
echo $e;
|
||||
return false;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
@@ -9,7 +9,7 @@ abstract class Database {
|
||||
/**
|
||||
* Zugangsdaten für die Datenbank
|
||||
*/
|
||||
private $dbName = "pbs2h22aal_av"; //Datenbankname
|
||||
private $dbName = "pbs2h22aal_SubwaySurfers"; //Datenbankname
|
||||
private $linkName = "mysql.pb.bib.de"; //Datenbank-Server
|
||||
//Administration: https://mysql.pb.bib.de/phpMyAdmin/
|
||||
private $user = "pbs2h22aal"; //Benutzername
|
||||
|
103
Model/GerichtModel.php
Normal file
103
Model/GerichtModel.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
//Programmierung: Sven Alteköster 100%
|
||||
//Getestet durch: Sven Alteköster 100%
|
||||
|
||||
namespace ppb\Model;
|
||||
|
||||
use ppb\Library\Msg;
|
||||
|
||||
class GerichtModel extends Database {
|
||||
|
||||
/**
|
||||
* Sucht die Gerichte in der Datenbank und gibt diese im json-Format zurück.
|
||||
* @param $id gibt die id, des gesuchten Objektes an. Wenn keine id angegeben wird, werden alle Einträge ausgegeben
|
||||
*/
|
||||
public function selectGericht($id = false) {
|
||||
$pdo = $this -> linkDB();
|
||||
$sql = "SELECT * FROM Gericht";
|
||||
$params = array();
|
||||
//Ist eine id angegeben wird der Datensatz in der Datenbank gesucht
|
||||
if($id !== false){
|
||||
$sql .= " WHERE id = :id";
|
||||
$params["id"] = $id;
|
||||
}
|
||||
//Ausführen des SQL befehls
|
||||
try {
|
||||
$stmt = $pdo -> prepare($sql);
|
||||
$stmt -> execute($params);
|
||||
}
|
||||
catch(\PDOException $e) {
|
||||
echo $e;
|
||||
return false;
|
||||
}
|
||||
$result = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
|
||||
//Die Datensätze werden nummeriert
|
||||
foreach($result as $key=>$row){
|
||||
$result[$key]["id"]+=0;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fügt ein Gericht in die Datenbank ein.
|
||||
* @param $data gibt die Attribute des Datensatzes an.
|
||||
*/
|
||||
public function insertGericht($data) {
|
||||
$pdo = $this -> linkDB();
|
||||
$sql = "INSERT INTO Gericht (" . implode(",", array_keys($data)) . ") VALUES(:" . implode(",:", array_keys($data)) . ")";
|
||||
|
||||
try{
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$result = $stmt->execute($data);
|
||||
}catch (\PDOExpecion $e) {
|
||||
echo $e;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updatet einen Datensatz in der Gericht Tabelle.
|
||||
* @param $id des Datensatzes
|
||||
* @param $data neue Parameter des Datensatzes
|
||||
*/
|
||||
public function updateGericht($id, $data){
|
||||
$pdo = $this->linkDB();
|
||||
$sql = "UPDATE Gericht SET ";
|
||||
//Fügt alle Parameter und einen Platzhalter in den SQL Befehl ein
|
||||
foreach (array_keys($data) as $key){
|
||||
$sql .= $key . " = :" . $key. ",";
|
||||
}
|
||||
$sql = substr_replace($sql, "", -1) . " WHERE id = :id";
|
||||
$data["id"] = $id;
|
||||
try{
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$result = $stmt->execute($data);
|
||||
}catch (\PDOExpection $e){
|
||||
echo $e;
|
||||
return false;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Löscht ein Gericht aus der Tabelle
|
||||
* @param $id des zu löschenden Gerichtes
|
||||
*/
|
||||
public function deleteGericht($id){
|
||||
$pdo = $this->linkDB();
|
||||
$sql = "DELETE FROM Gericht WHERE id = :id";
|
||||
$params = array();
|
||||
$params[":id"] = $id;
|
||||
try{
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$result = $stmt->execute($params);
|
||||
}catch (\PDOExpection $e){
|
||||
echo $e;
|
||||
return false;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
@@ -3,9 +3,9 @@
|
||||
// Programmiert durch Samuel Wolff
|
||||
// Getestet durch: Nicht getestet
|
||||
|
||||
namespace kindergartenverwaltung\Model;
|
||||
namespace ppb\Model;
|
||||
|
||||
use kindergartenverwaltung\Library\Msg;
|
||||
use ppb\Library\Msg;
|
||||
|
||||
|
||||
class KindModel extends Database{
|
||||
@@ -19,14 +19,14 @@ public function getKind($parentId){
|
||||
|
||||
// Das mitgeben einer Id erlaubt es die Kinder eines bestimmten Benutzerkontos anzeigen zu lassen,
|
||||
// während das leerlassen alle Kinder ausgibt.
|
||||
id($parentId !== false){
|
||||
if($parentId !== false){
|
||||
$sql .= " WHERE bid=:id;";
|
||||
$params[":id"] = $parentId;
|
||||
}
|
||||
|
||||
try{
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->excute($params);
|
||||
$stmt->execute($params);
|
||||
}
|
||||
catch(\PDOException $e){
|
||||
return false;
|
||||
@@ -38,6 +38,7 @@ public function getKind($parentId){
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Updated die Daten eines Kindes
|
||||
*
|
||||
* @param $kindId Id des Kindes
|
||||
@@ -76,6 +77,9 @@ public function updateKind($kindId, $data){
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Fügt ein Kind mit gegebenen Daten in die Datenbank hinzu
|
||||
*
|
||||
* @param $data Die Daten für das neue Kind
|
||||
*/
|
||||
public function addKind($data){
|
||||
@@ -112,7 +116,13 @@ public function addKind($data){
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Löscht ein Kind mit einer gegebenen Id aus der Datenbank
|
||||
*
|
||||
* @param $kindId Die Id des zu löschenden Kindes
|
||||
*
|
||||
*/
|
||||
public function deleteKind($kindId){
|
||||
$pdo = $this->linkDB();
|
||||
|
||||
|
Reference in New Issue
Block a user