|
|
|
@ -19,16 +19,24 @@ class GatewayNews
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getNews()
|
|
|
|
|
public function getNews($page,$nbArticlePage)
|
|
|
|
|
{
|
|
|
|
|
$query = "SELECT * FROM news order by pubdate;";
|
|
|
|
|
$this->con->executeQuery($query, array());
|
|
|
|
|
$query = "SELECT * FROM news order by pubdate LIMIT :debut,:fin;";
|
|
|
|
|
$this->con->executeQuery($query, array(':debut' => array($nbArticlePage * ($page-1),PDO::PARAM_INT),
|
|
|
|
|
':fin' => array($nbArticlePage,PDO::PARAM_INT)
|
|
|
|
|
));
|
|
|
|
|
$results=$this->con->getResults();
|
|
|
|
|
Foreach ($results as $article){
|
|
|
|
|
$listeNews[] = new News($article["title"],$article['description'],$article['pubdate'],$article['link']);
|
|
|
|
|
}
|
|
|
|
|
return $listeNews;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getNbNews(){
|
|
|
|
|
$query = "SELECT count(*) FROM news;";
|
|
|
|
|
$this->con->executeQuery($query, array());
|
|
|
|
|
return $this->con->getResults()[0]["count(*)"];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
|