|
|
|
@ -24,7 +24,7 @@ class NewsGateway
|
|
|
|
|
*/
|
|
|
|
|
public function getPaginatedRecentNews(int $page = 1, int $limit = 10): array
|
|
|
|
|
{
|
|
|
|
|
$req = $this->pdo->prepare('SELECT title, LEFT(content, ' . self::EXCERPT_LENGTH . ') content, publication_date FROM news ORDER BY publication_date DESC LIMIT :limit OFFSET :offset;');
|
|
|
|
|
$req = $this->pdo->prepare('SELECT id_news, title, LEFT(content, ' . self::EXCERPT_LENGTH . ') content, publication_date FROM news ORDER BY publication_date DESC LIMIT :limit OFFSET :offset;');
|
|
|
|
|
$req->bindValue('limit', $limit, PDO::PARAM_INT);
|
|
|
|
|
$req->bindValue('offset', ($page - 1) * $limit, PDO::PARAM_INT);
|
|
|
|
|
if (!$req->execute()) {
|
|
|
|
@ -61,6 +61,6 @@ class NewsGateway
|
|
|
|
|
|
|
|
|
|
private function createNews(array $data): News
|
|
|
|
|
{
|
|
|
|
|
return new News($data['title'], $data['content'], DateTime::createFromFormat('Y-m-d H:i:s', $data['publication_date']));
|
|
|
|
|
return new News(intval($data['id_news']), $data['title'], $data['content'], DateTime::createFromFormat('Y-m-d H:i:s', $data['publication_date']));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|