Refactor Controller and models anhand der bibarts.sql und unbrauchbare Controllers und Models entfernt.
This commit is contained in:
@@ -8,8 +8,8 @@ class NewsModel extends Database {
|
||||
|
||||
public function getNewsById($newsId) {
|
||||
$pdo = $this->linkDB();
|
||||
$sql = "SELECT * FROM news WHERE newsid = :newsid;";
|
||||
$params = [":newsid" => $newsId];
|
||||
$sql = "SELECT * FROM news WHERE news_id = :news_id;";
|
||||
$params = [":news_id" => $newsId];
|
||||
try {
|
||||
$sth = $pdo->prepare($sql);
|
||||
$sth->execute($params);
|
||||
@@ -22,12 +22,12 @@ class NewsModel extends Database {
|
||||
|
||||
public function updateNews($newsId, $news) {
|
||||
$pdo = $this->linkDB();
|
||||
$sql = "UPDATE news SET name = :name, beschreibung = :beschreibung, datum = :datum WHERE newsid = :newsid;";
|
||||
$sql = "UPDATE news SET name = :name, description = :description, date = :date WHERE news_id = :news_id;";
|
||||
$params = [
|
||||
":name" => $news['titel'],
|
||||
":beschreibung" => $news['inhalt'],
|
||||
":datum" => $news['datum'],
|
||||
":newsid" => $newsId
|
||||
":description" => $news['inhalt'],
|
||||
":date" => $news['datum'],
|
||||
":news_id" => $newsId
|
||||
];
|
||||
try {
|
||||
$sth = $pdo->prepare($sql);
|
||||
@@ -41,7 +41,7 @@ class NewsModel extends Database {
|
||||
|
||||
public function getNews() {
|
||||
$pdo = $this->linkDB();
|
||||
$sql = "SELECT * FROM news ORDER BY datum DESC;";
|
||||
$sql = "SELECT * FROM news ORDER BY date DESC;";
|
||||
try {
|
||||
$sth = $pdo->prepare($sql);
|
||||
$sth->execute();
|
||||
@@ -54,11 +54,11 @@ class NewsModel extends Database {
|
||||
|
||||
public function createNews($news) {
|
||||
$pdo = $this->linkDB();
|
||||
$sql = "INSERT INTO news (name, beschreibung, datum) VALUES (:name, :beschreibung, :datum);";
|
||||
$sql = "INSERT INTO news (name, description, date) VALUES (:name, :description, :date);";
|
||||
$params = [
|
||||
":name" => $news['titel'],
|
||||
":beschreibung" => $news['inhalt'],
|
||||
":datum" => $news['datum']
|
||||
":description" => $news['inhalt'],
|
||||
":date" => $news['datum']
|
||||
];
|
||||
try {
|
||||
$sth = $pdo->prepare($sql);
|
||||
@@ -72,8 +72,8 @@ class NewsModel extends Database {
|
||||
|
||||
public function deleteNews($newsId) {
|
||||
$pdo = $this->linkDB();
|
||||
$sql = "DELETE FROM news WHERE newsid = :newsid;";
|
||||
$params = [":newsid" => $newsId];
|
||||
$sql = "DELETE FROM news WHERE news_id = :news_id;";
|
||||
$params = [":news_id" => $newsId];
|
||||
try {
|
||||
$sth = $pdo->prepare($sql);
|
||||
$sth->execute($params);
|
||||
|
Reference in New Issue
Block a user