From c842e6c853469cda9be7cf866e7da69b33bb672b Mon Sep 17 00:00:00 2001 From: Roxane Date: Wed, 8 Nov 2023 20:11:59 +0100 Subject: [PATCH] ArticleGateway created id add to the article class --- mvc_PSR4_twig/DAL/ArticleGateway.php | 19 ++++++++++ mvc_PSR4_twig/modeles/Article.php | 53 +++++++++------------------- 2 files changed, 35 insertions(+), 37 deletions(-) diff --git a/mvc_PSR4_twig/DAL/ArticleGateway.php b/mvc_PSR4_twig/DAL/ArticleGateway.php index 0008a0a..cd0e31f 100755 --- a/mvc_PSR4_twig/DAL/ArticleGateway.php +++ b/mvc_PSR4_twig/DAL/ArticleGateway.php @@ -1,6 +1,25 @@ con = $con; + } + + public function getAllArticles():array + { + $query = 'SELECT * FROM Article;'; + $this->con->executeQuery($query, array()); + return $this->con->getResults(); + } } \ No newline at end of file diff --git a/mvc_PSR4_twig/modeles/Article.php b/mvc_PSR4_twig/modeles/Article.php index 14e9e2e..0a17611 100755 --- a/mvc_PSR4_twig/modeles/Article.php +++ b/mvc_PSR4_twig/modeles/Article.php @@ -4,6 +4,7 @@ namespace modeles; class Article { + private int $id; private string $title; private string $date; private string $description; @@ -12,6 +13,7 @@ class Article private string $mediaContent; /** + * @param int $id * @param string $title * @param string $date * @param string $description @@ -19,8 +21,9 @@ class Article * @param string $link * @param string $mediaContent */ - public function __construct(string $title, string $date, string $description, string $guid, string $link, string $mediaContent) + public function __construct(int $id, string $title, string $date, string $description, string $guid, string $link, string $mediaContent) { + $this->id = $id; $this->title = $title; $this->date = $date; $this->description = $description; @@ -29,99 +32,75 @@ class Article $this->mediaContent = $mediaContent; } - /** - * @return string - */ + public function getId(): int + { + return $this->id; + } + + public function setId(int $id): void + { + $this->id = $id; + } + public function getTitle(): string { return $this->title; } - /** - * @param string $title - */ public function setTitle(string $title): void { $this->title = $title; } - /** - * @return string - */ public function getDate(): string { return $this->date; } - /** - * @param string $date - */ public function setDate(string $date): void { $this->date = $date; } - /** - * @return string - */ public function getDescription(): string { return $this->description; } - /** - * @param string $description - */ public function setDescription(string $description): void { $this->description = $description; } - /** - * @return string - */ public function getGuid(): string { return $this->guid; } - /** - * @param string $guid - */ public function setGuid(string $guid): void { $this->guid = $guid; } - /** - * @return string - */ public function getLink(): string { return $this->link; } - /** - * @param string $link - */ public function setLink(string $link): void { $this->link = $link; } - /** - * @return string - */ public function getMediaContent(): string { return $this->mediaContent; } - /** - * @param string $mediaContent - */ public function setMediaContent(string $mediaContent): void { $this->mediaContent = $mediaContent; } + + } \ No newline at end of file