Pagine la liste des news récentes

This commit is contained in:
2022-11-30 10:45:06 +01:00
parent 9519287329
commit 2c8e49e560
5 changed files with 79 additions and 6 deletions

View File

@@ -37,6 +37,15 @@ class NewsGateway
return $news;
}
public function getCount(): int
{
$req = $this->pdo->query('SELECT COUNT(*) nb FROM news;');
if ($req === false) {
return 0;
}
return intval($req->fetch()['nb']);
}
public function getById(int $id): News
{
$req = $this->pdo->prepare('SELECT * FROM news WHERE id_news=:id;');