$req = $this->pdo->prepare('SELECT * FROM comment WHERE news_id = :id ORDER BY publication_date DESC');
$req = $this->pdo->prepare('SELECT c.*, u.login author_login FROM comment c INNER JOIN registered_user u ON u.id_user = c.author_id WHERE c.news_id = :id ORDER BY c.publication_date ASC');
$req->bindValue(':id', $id, PDO::PARAM_INT);
if (!$req->execute()) {
return [];
@ -76,6 +76,16 @@ class CommentGateway
private function createComment(array $data): Comment
{
return new Comment(intval($data['id_comment']),intval($data['news_id']), DateTime::createFromFormat('Y-m-d H:i:s', $data['publication_date']), $data['content'], intval($data['author_id']));