<?php

class Article
{
	private $ID;
	private $Title;
	private $Cover;
	private $Author;
	private $Content;
	private $PostDate;
	private $Comments;
	private $Description;

	public function __construct(int $id)
	{
		$this->ID = $id;

		$result = Database::select('articles', '*', 'WHERE id = :id', data: [':id' => $id]);

		$ArticleInfo = $result->fetch();

		$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'];
	}

	public function __get($what)
	{
		return property_exists($this, $what) ? $this->{$what} : null;
	}
}
