diff --git a/fluxRSS/DAL/ArticleGateway.php b/fluxRSS/DAL/ArticleGateway.php index 7818920..89e43ec 100755 --- a/fluxRSS/DAL/ArticleGateway.php +++ b/fluxRSS/DAL/ArticleGateway.php @@ -48,4 +48,13 @@ class ArticleGateway 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."); + } + } } \ No newline at end of file diff --git a/fluxRSS/model/Parser.php b/fluxRSS/model/Parser.php index a965433..287e26d 100755 --- a/fluxRSS/model/Parser.php +++ b/fluxRSS/model/Parser.php @@ -3,6 +3,7 @@ namespace model; use DAL\ArticleGateway; +use DAL\Connection; use DAL\FluxGateway; use DOMDocument; use Exception; @@ -62,13 +63,25 @@ class Parser /** * @throws Exception */ - public function addAllArticles(){ - $allFlux = $this->fluxGateway->findAllFlux(); + public function addAllArticles() + { + $this->articleGateway->removeAllArticleForParser(); + $allFlux = $this->fluxGateway->findAllFlux(); + var_dump($allFlux); $allArticles = $this->parseAll($allFlux); - + var_dump($allArticles); foreach ($allArticles as $article) { $this->articleGateway->addArticle($article); } + return $allArticles; } -} \ No newline at end of file + +} +$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()); + + +