MS-Tropical/app/classes/Article.php

68 lines
1.2 KiB
PHP
Raw Normal View History

<?php
2024-06-29 08:07:30 -05:00
class Article {
2024-06-29 08:07:30 -05:00
private $ID;
private $Title;
private $Cover;
private $Author;
private $Content;
private $PostDate;
private $Comments;
private $Description;
2024-06-29 08:07:30 -05:00
public function __construct($id) {
2024-06-29 08:07:30 -05:00
$this->ID = $id;
2024-06-29 08:07:30 -05:00
$this->getArticle($id);
2024-06-29 08:07:30 -05:00
}
2024-06-29 08:07:30 -05:00
private function getArticle($id) {
2024-06-29 08:07:30 -05:00
$db = new DatabaseModule();
2024-06-29 08:07:30 -05:00
$getArticle = $db->Handle->prepare('SELECT * FROM ms_articles WHERE id = :id');
$getArticle->bindValue(':id', $id, PDO::PARAM_INT);
$getArticle->execute();
2024-06-29 08:07:30 -05:00
$ArticleInfo = $getArticle->fetch();
2024-06-29 08:07:30 -05:00
$getArticle->closeCursor();
2024-06-29 08:07:30 -05:00
$this->Title = $ArticleInfo['articleName'];
$this->Cover = $ArticleInfo['articleCover'];
$this->Author = $ArticleInfo['articleAuthor'];
$this->Content = $ArticleInfo['articleContent'];
$this->PostDate = betterDate($ArticleInfo['articleDate']);
$this->Comments = $ArticleInfo['articleComments'];
$this->Description = $ArticleInfo['articleDescription'];
2024-06-29 08:07:30 -05:00
}
2024-06-29 08:07:30 -05:00
public function __get($what) {
2024-06-29 08:07:30 -05:00
if(property_exists($this, $what)) {
2024-06-29 08:07:30 -05:00
return $this->{$what};
2024-06-29 08:07:30 -05:00
} else {
2024-06-29 08:07:30 -05:00
return null;
2024-06-29 08:07:30 -05:00
}
2024-06-29 08:07:30 -05:00
}
2024-06-29 08:07:30 -05:00
public function update($what) {
2024-06-29 08:07:30 -05:00
}
}
2024-06-29 08:07:30 -05:00
?>