Merge pull request 'feature/article' (#3) from feature/article into pre-master

Reviewed-on: #3
pull/6/head
Maxime POINT 2 years ago
commit 9d1b89898a

@ -1,7 +1,7 @@
<?php <?php
namespace DAL; namespace DAL;
use App\modeles\Article; use metier\Article;
use PDO; use PDO;
class ArticleGateway class ArticleGateway
{ {
@ -22,4 +22,15 @@ class ArticleGateway
return $this->con->getResults(); return $this->con->getResults();
} }
public function addArticle(Article $article){
$query = 'INSERT INTO Article VALUES (:id,:title,to_date(:date,"Dy, DD Mon YYYY"),:description,:guid,:link,:mediaContent,:provenance);';
$this->con->executeQuery($query, array( ':id' => array($article->getId(), PDO::PARAM_STR),
':title' => array($article->getTitle(), PDO::PARAM_STR),
':date' => array($article->getDate(),PDO::PARAM_STR),
':description' => array($article->getDescription(),PDO::PARAM_STR),
':guid' => array($article->getGuid(),PDO::PARAM_STR),
':link' => array($article->getLink(),PDO::PARAM_STR),
':mediaContent' => array($article->getMediaContent(),PDO::PARAM_STR),
':provenance' => array($article->getProvenance(),PDO::PARAM_INT)));
}
} }

@ -9,6 +9,6 @@ $rep = __DIR__ . '/../';
//BD //BD
$base = 'sasa'; $base = 'dbrorossetto';
$login = ''; $login = 'rorossetto';
$mdp = ''; $mdp = 'tpphp';

@ -4,11 +4,13 @@ namespace model;
use DAL; use DAL;
use metier; use metier;
require_once "config/config.php";
class ArticleModel class ArticleModel
{ {
public static function getArticles() : array public static function getArticles() : array
{ {
$gwArticle = new DAL\ArticleGateway(new DAL\Connection('mysql:host = localhost; dbname = dbrorossetto', 'rorossetto', 'tpphp')); $gwArticle = new DAL\ArticleGateway(new DAL\Connection( $base, $login, $mdp));
$res = $gwArticle->getAllArticles(); $res = $gwArticle->getAllArticles();
foreach($res as $row){ foreach($res as $row){
$tabArticle[] = new metier\Article($row['id'], $row['title'],$row['datePub'],$row['description'],$row['guid'],$row['link'],$row['mediaContent'],$row['provenance'] ); $tabArticle[] = new metier\Article($row['id'], $row['title'],$row['datePub'],$row['description'],$row['guid'],$row['link'],$row['mediaContent'],$row['provenance'] );

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save