Compare commits

...

14 Commits

3 changed files with 44 additions and 1 deletions

View File

@ -18,6 +18,18 @@ class BenutzerController
$this->db = new BenutzerModel();
}
public function getBenutzer() {
$result = $this->db->selectBenutzer();
if (isset($_GET["name"])) {
if ($result)
$result = $result[0];
else
$result = false;
}
return json_encode($result);
}
// Updated einen Benutzer
public function updateBenutzer($elternId, $data)
{

View File

@ -48,7 +48,7 @@ class KindController
{
$result = $this->db->deleteKind($kindId);
return $result;
return json_encode($result);
}
}

View File

@ -9,6 +9,37 @@ use ppb\Library\Msg;
class BenutzerModel extends Database
{
public function selectBenutzer()
{
$pdo = $this->linkDB();
$params = array();
$sql = "SELECT * FROM Benutzerkonto";
if(isset($_GET["name"])){
$params[":name"] = $_GET["name"];
$sql .= " WHERE name = :name";
}
//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;
}
/**