You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.2 KiB

<?php
require_once("news.php");
class GatewayNews
{
private $con;
public function __construct($con){
$this->con = $con;
}
public function addNews($news)
{
$query = "insert into news(title,description,pubdate,link) values (:title,:description,:pubdate,:link);";
$this->con->executeQuery($query, array(':title' => array($news->getTitle(), PDO::PARAM_STR),
':description' => array($news->getDescription(), PDO::PARAM_STR),
':pubdate' => array($news->getPubdate(), PDO::PARAM_STR),
':link' => array($news->getLink(), PDO::PARAM_STR)
)
);
}
public function getNews()
{
$query = "SELECT * FROM news order by pubdate;";
$this->con->executeQuery($query, array());
$results=$this->con->getResults();
Foreach ($results as $article){
$listeNews[] = new News($article["title"],$article['description'],$article['pubdate'],$article['link']);
}
return $listeNews;
}
}
?>