|
|
@ -22,7 +22,7 @@ class ArticleGateway
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function getAllArticles():array
|
|
|
|
public function getAllArticles():array
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$query = 'SELECT * FROM Article;';
|
|
|
|
$query = 'SELECT * FROM Article ORDER BY datePub DESC;';
|
|
|
|
$this->con->executeQuery($query, array());
|
|
|
|
$this->con->executeQuery($query, array());
|
|
|
|
return $this->con->getResults();
|
|
|
|
return $this->con->getResults();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -31,7 +31,7 @@ class ArticleGateway
|
|
|
|
* @throws Exception
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function addArticle(Article $article){
|
|
|
|
public function addArticle(Article $article){
|
|
|
|
$query = 'INSERT INTO Article VALUES (:id,:title,to_date(:date,"Dy, DD Mon YYYY"),:description,:guid,:link,:mediaContent,:provenance);';
|
|
|
|
$query = "INSERT INTO Article VALUES (:id,:title,STR_TO_DATE(:datePub, '%d/%m/%y %H:%i'),:description,:guid,:link,:mediaContent,:provenance);";
|
|
|
|
$this->con->executeQuery($query, array(':id' => array($article->getId(), PDO::PARAM_STR),
|
|
|
|
$this->con->executeQuery($query, array(':id' => array($article->getId(), PDO::PARAM_STR),
|
|
|
|
':title' => array($article->getTitle(), PDO::PARAM_STR),
|
|
|
|
':title' => array($article->getTitle(), PDO::PARAM_STR),
|
|
|
|
':datePub' => array($article->getDate(), PDO::PARAM_STR),
|
|
|
|
':datePub' => array($article->getDate(), PDO::PARAM_STR),
|
|
|
|