modification on parser to test

feature/article
Roxane ROSSETTO 1 year ago
parent 76787c26ef
commit 5de925155f

@ -48,4 +48,13 @@ class ArticleGateway
throw new Exception("PDO error"); throw new Exception("PDO error");
} }
} }
public function removeAllArticleForParser(){
try{
$query = 'DELETE FROM Article;';
$this->con->executeQuery($query);
}catch(\PDOException $p){
throw new Exception("Data is not delete.");
}
}
} }

@ -3,6 +3,7 @@
namespace model; namespace model;
use DAL\ArticleGateway; use DAL\ArticleGateway;
use DAL\Connection;
use DAL\FluxGateway; use DAL\FluxGateway;
use DOMDocument; use DOMDocument;
use Exception; use Exception;
@ -62,13 +63,25 @@ class Parser
/** /**
* @throws Exception * @throws Exception
*/ */
public function addAllArticles(){ public function addAllArticles()
$allFlux = $this->fluxGateway->findAllFlux(); {
$this->articleGateway->removeAllArticleForParser();
$allFlux = $this->fluxGateway->findAllFlux();
var_dump($allFlux);
$allArticles = $this->parseAll($allFlux); $allArticles = $this->parseAll($allFlux);
var_dump($allArticles);
foreach ($allArticles as $article) { foreach ($allArticles as $article) {
$this->articleGateway->addArticle($article); $this->articleGateway->addArticle($article);
} }
return $allArticles;
} }
}
}
$gwArt = new ArticleGateway(new Connection('mysql:host=londres.uca.local;dbname=dbrorossetto', 'rorossetto', 'tpphp'));
$gwFl = new FluxGateway(new Connection('mysql:host=londres.uca.local;dbname=dbrorossetto', 'rorossetto', 'tpphp'));
$pars = new Parser( $gwFl,$gwArt);
var_dump($pars->addAllArticles());

Loading…
Cancel
Save