From d03131beea5645e28b9a390517c26f65f0e8e0ff Mon Sep 17 00:00:00 2001 From: "maxime.point2" Date: Sat, 18 Nov 2023 20:32:15 +0100 Subject: [PATCH] modif delete flux --- fluxRSS/src/DAL/ArticleGateway.php | 9 +++++++++ fluxRSS/src/DAL/FluxGateway.php | 5 +++++ fluxRSS/src/controleur/AdminControleur.php | 6 +++++- fluxRSS/src/model/ArticleModel.php | 6 ++++++ fluxRSS/src/model/FluxModel.php | 5 +++++ fluxRSS/src/test/test.php | 1 + fluxRSS/templates/listFlux.html | 2 +- 7 files changed, 32 insertions(+), 2 deletions(-) diff --git a/fluxRSS/src/DAL/ArticleGateway.php b/fluxRSS/src/DAL/ArticleGateway.php index e08f763..a6adc1a 100755 --- a/fluxRSS/src/DAL/ArticleGateway.php +++ b/fluxRSS/src/DAL/ArticleGateway.php @@ -47,6 +47,15 @@ class ArticleGateway $this->con->executeQuery($query); } + public function removeAllArticleFromFlux(int $idFlux){ + try { + $query = 'DELETE FROM Article WHERE Provenance = :idFlux;'; + $this->con->executeQuery($query, array(':idFlux' => array($idFlux, PDO::PARAM_INT))); + }catch(\PDOException $p){ + throw new Exception("Data of flux is not delete."); + } + } + public function findArticleByFlux(int $flux){ $query = 'SELECT * FROM Article WHERE provenance = :flux;'; $this->con->executeQuery($query, array(':flux' => array($flux, PDO::PARAM_INT))); diff --git a/fluxRSS/src/DAL/FluxGateway.php b/fluxRSS/src/DAL/FluxGateway.php index bcdbcec..3675a06 100755 --- a/fluxRSS/src/DAL/FluxGateway.php +++ b/fluxRSS/src/DAL/FluxGateway.php @@ -33,6 +33,11 @@ class FluxGateway $this->con->executeQuery($query, array(':flux' => array($flux, PDO::PARAM_STR))); } + public function removeFluxById(int $id){ + $query = 'DELETE FROM Flux WHERE id = :id;'; + $this->con->executeQuery($query, array(':id' => array($id, PDO::PARAM_INT))); + } + public function findAllFlux(){ $query = 'SELECT * FROM Flux;'; $this->con->executeQuery($query); diff --git a/fluxRSS/src/controleur/AdminControleur.php b/fluxRSS/src/controleur/AdminControleur.php index 6166e7c..8d862fc 100755 --- a/fluxRSS/src/controleur/AdminControleur.php +++ b/fluxRSS/src/controleur/AdminControleur.php @@ -2,6 +2,7 @@ namespace controleur; +use DAL\ArticleGateway; use http\Exception; use metier\Flux; use model\AdminModel; @@ -122,8 +123,11 @@ class AdminControleur public function deleteFlux(){ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['flux'])){ + $articleModel = new ArticleModel(); $fluxModel = new FluxModel(); - $fluxModel->removeFluxBySrc($_POST['flux']); + var_dump($_POST); + $articleModel->removeAticleIdFlux(intval($_POST['flux'])); + $fluxModel->removeFluxById(intval($_POST['flux'])); $_REQUEST['action'] = 'listFlux'; $this->init(); } diff --git a/fluxRSS/src/model/ArticleModel.php b/fluxRSS/src/model/ArticleModel.php index 0da42c6..372dd4a 100755 --- a/fluxRSS/src/model/ArticleModel.php +++ b/fluxRSS/src/model/ArticleModel.php @@ -66,4 +66,10 @@ class ArticleModel $dicoFluxArticle = [$flux,$tabArticle]; return $dicoFluxArticle; } + + public static function removeAticleIdFlux(int $idFlux) + { + $gwArticle = new ArticleGateway(new Connection('mysql:host=londres.uca.local;dbname=dbrorossetto','rorossetto','tpphp')); + $gwArticle->removeAllArticleFromFlux($idFlux); + } } \ No newline at end of file diff --git a/fluxRSS/src/model/FluxModel.php b/fluxRSS/src/model/FluxModel.php index a79eedb..5a329c3 100755 --- a/fluxRSS/src/model/FluxModel.php +++ b/fluxRSS/src/model/FluxModel.php @@ -39,6 +39,11 @@ class FluxModel $gateway->removeFlux($flux); } + public function removeFluxById(int $id){ + $gateway = new FluxGateway(new Connection('mysql:host=londres.uca.local;dbname=dbrorossetto','rorossetto','tpphp')); + $gateway->removeFluxById($id); + } + public function removeFluxBySrc(string $flux) { $gateway = new FluxGateway(new Connection('mysql:host=londres.uca.local;dbname=dbrorossetto','rorossetto','tpphp')); $gateway->removeFluxBySrc($flux); diff --git a/fluxRSS/src/test/test.php b/fluxRSS/src/test/test.php index ff5c34a..068db67 100755 --- a/fluxRSS/src/test/test.php +++ b/fluxRSS/src/test/test.php @@ -11,3 +11,4 @@ $gwArt = new ArticleGateway(new Connection('mysql:host=londres.uca.local;dbname= $gwFl = new FluxGateway(new Connection('mysql:host=londres.uca.local;dbname=dbrorossetto', 'rorossetto', 'tpphp')); $pars = new Parser( $gwFl,$gwArt); +var_dump($pars); \ No newline at end of file diff --git a/fluxRSS/templates/listFlux.html b/fluxRSS/templates/listFlux.html index 14d182e..b503f89 100755 --- a/fluxRSS/templates/listFlux.html +++ b/fluxRSS/templates/listFlux.html @@ -9,7 +9,7 @@
{{ value.getFlux() }}
- +