refactoring

This commit is contained in:
NOrtmann1
2026-05-26 15:01:17 +02:00
parent 2044853f94
commit b15421efee
4 changed files with 20 additions and 5 deletions
+53
View File
@@ -0,0 +1,53 @@
<?php
require_once databaseDAO::class;
/*
* Klasse: DatabaseDummie
* TODO Beschreibung hinzufügen
*/
class FileDatabase implements databaseDAO {
public function newArticle($title, $content, $author) {
$newData = array(
"title" => $title,
"content" => $content,
"author" => $author,
"email" => $_POST["Email"],
"date" => date("d.m.Y, H:i")
);
$newData = base64_encode(serialize($newData));
if (!file_exists("articles.txt")) {
$newData = fopen("articles.txt", "xb");
fclose($newData);
}
$previousData = file_get_contents("gaestebuch.txt");
if (file_put_contents("gaestebuch.txt", "$newData\n$previousData")) {
// TODO: Vernünftige Rückmeldung implementieren.
echo "Artikel erfolgreich gespeichert!";
} else {
// TODO: passende Exceptions werfen.
echo "Fehler!";
}
}
public function updateArticle($id, $title, $content, $author)
{
// TODO: Implement updateArticle() method.
}
public function deleteArticle($id)
{
// TODO: Implement deleteArticle() method.
}
public function getArticle($id)
{
// TODO: Implement getArticle() method.
}
public function getAllArticles()
{
// TODO: Implement getAllArticles() method.
}
}
?>