From ce81b7af42252b43a625887dced26c3597aa0dd4 Mon Sep 17 00:00:00 2001 From: Baptiste D Date: Sun, 5 Nov 2023 22:48:30 +0100 Subject: [PATCH] =?UTF-8?q?ins=C3=A9rer=20&=20r=C3=A9cuperer=20images=20fo?= =?UTF-8?q?nctionnel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- php/src/controleur/UtilisateurControleur.php | 20 ++++++++- php/src/gateway/ImageGateway.php | 46 +------------------- php/src/modele/Image.php | 5 ++- 3 files changed, 24 insertions(+), 47 deletions(-) diff --git a/php/src/controleur/UtilisateurControleur.php b/php/src/controleur/UtilisateurControleur.php index c646767..6f13247 100755 --- a/php/src/controleur/UtilisateurControleur.php +++ b/php/src/controleur/UtilisateurControleur.php @@ -100,8 +100,21 @@ class UtilisateurControleur protected function creerOffre() { + /* global $twig; echo $twig->render('testImage.html', []); + /* + * */ + $con = new Connection("mysql:host=localhost;dbname=dbAlica",'test','test'); + + $imgGw = new ImageGateway($con); + + $imglist = $imgGw->getAll(); + + //echo $imglist[0]->getBlob(); + // echo $imglist[0]->toString(); + + echo 'mon image'; } @@ -116,12 +129,17 @@ class UtilisateurControleur return; } - $con = new Connection("mysql:host=localhost;dbname=dbAlida",'test','test'); + $con = new Connection("mysql:host=localhost;dbname=dbAlica",'test','test'); $imgGw = new ImageGateway($con); $imgGw->insertImage($img); + + //echo $img->getBlob(); + // echo 'mon image'; + echo "

Image inserée

"; + } diff --git a/php/src/gateway/ImageGateway.php b/php/src/gateway/ImageGateway.php index 09a7ae0..e1c9bf8 100644 --- a/php/src/gateway/ImageGateway.php +++ b/php/src/gateway/ImageGateway.php @@ -42,50 +42,6 @@ class ImageGateway )); } - public function updateName(int $id, string $newName) - { - $query = 'UPDATE Image SET nom=:new WHERE id=:i'; - $this->con->executeQuery($query, array( - ':i' => array($id, PDO::PARAM_INT), - ':new' => array($newName, PDO::PARAM_STR) - )); - } - - public function updateDesc(int $id, string $newDesc) - { - $query = 'UPDATE Image SET desc=:new WHERE id=:i'; - $this->con->executeQuery($query, array( - ':i' => array($id, PDO::PARAM_INT), - ':new' => array($newDesc, PDO::PARAM_STR) - )); - } - - public function updateTaille(int $id, string $newTaille) - { - $query = 'UPDATE Image SET taille=:new WHERE id=:i'; - $this->con->executeQuery($query, array( - ':i' => array($id, PDO::PARAM_INT), - ':new' => array($newTaille, PDO::PARAM_STR) - )); - } - - public function updateType(int $id, string $newType) - { - $query = 'UPDATE Image SET type=:new WHERE id=:i'; - $this->con->executeQuery($query, array( - ':i' => array($id, PDO::PARAM_INT), - ':new' => array($newType, PDO::PARAM_STR) - )); - } - - public function updateBlob(int $id, string $newBlob) - { - $query = 'UPDATE Image SET blob=:new WHERE id=:i'; - $this->con->executeQuery($query, array( - ':i' => array($id, PDO::PARAM_INT), - ':new' => array($newBlob, PDO::PARAM_STR) - )); - } public function delete(int $id) { @@ -112,7 +68,7 @@ class ImageGateway $res = $this->con->getResults(); $array = []; foreach ($res as $r) { - $array[] = new Image($r['nom'], $r['desc'], $r['taille'], $r['type'], $r['blob']); + $array[] = new Image($r['nom'], $r['taille'], $r['type'], $r['blob']); } return $array; diff --git a/php/src/modele/Image.php b/php/src/modele/Image.php index 3860291..43b9fe6 100644 --- a/php/src/modele/Image.php +++ b/php/src/modele/Image.php @@ -15,7 +15,6 @@ class Image /** * @param string $name - * @param string $desc * @param string $taille * @param string $type * @param string $blob @@ -50,5 +49,9 @@ class Image return $this->blob; } + public function toString() : string { + return "Image : " . $this->name . " " . $this->taille . " " . $this->type . " blob " . $this->blob; + } + } \ No newline at end of file