From 39a8ef2ff531a399923ad317bf85371aba3c9eba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mu=C3=B1oz=20Garcia?= <73303506+danimu03@users.noreply.github.com> Date: Thu, 13 May 2021 20:06:05 +0200 Subject: [PATCH] update --- assets/php/common/film.php | 6 +++++- assets/php/common/film_dao.php | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/assets/php/common/film.php b/assets/php/common/film.php index 92988eb..f34a40d 100644 --- a/assets/php/common/film.php +++ b/assets/php/common/film.php @@ -8,14 +8,16 @@ private $_duration; //Film duration. private $_language; //Film language. private $_description; //Film description. + private $_img; //Constructor: - function __construct($id, $tittle, $duration, $language, $description){ + function __construct($id, $tittle, $duration, $language, $description, $img){ $this->_id = $id; $this->_tittle = $tittle; $this->_duration = $duration; $this->_language = $language; $this->_description = $description; + $this->_img = $img; } //Methods: @@ -31,5 +33,7 @@ public function getLanguage(){return $this->_language;} public function setDescription($description){ $this->_description = $description;} public function getDescription(){return $this->_description;} + public function setImg($img){ $this->_img = $img;} + public function getImg(){return $this->_img;} } ?> \ No newline at end of file diff --git a/assets/php/common/film_dao.php b/assets/php/common/film_dao.php index cc7c1f4..7dda4ab 100644 --- a/assets/php/common/film_dao.php +++ b/assets/php/common/film_dao.php @@ -15,10 +15,10 @@ //Methods: //Create a new Session. - public function createFilm($id, $tittle, $duration, $language, $description){ - $sql = sprintf( "INSERT INTO `film`( `id`, `tittle`, `duration`, `language`,`description`) - VALUES ( '%d', '%s', '%d', '%s','%s')", - $id, $tittle, $duration, $language, $description); + public function createFilm($id, $tittle, $duration, $language, $description, $img){ + $sql = sprintf( "INSERT INTO `film`( `id`, `tittle`, `duration`, `language`,`description`, `img`) + VALUES ( '%d', '%s', '%d', '%s','%s', '%s')", + $id, $tittle, $duration, $language, $description, $img); $resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database'); return $resul; @@ -44,7 +44,7 @@ $resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database'); while($fila=$resul->fetch_assoc()){ - $films[] = $this->loadFilm($fila["id"], $fila["tittle"], $fila["duration"], $fila["language"], $fila["description"]); + $films[] = $this->loadFilm($fila["id"], $fila["tittle"], $fila["duration"], $fila["language"], $fila["description"], $fila["img"]); } $resul->free(); return $films; @@ -84,10 +84,10 @@ } //Edit a film. - public function editFilm($id, $tittle, $duration, $language,$description){ - $sql = sprintf( "UPDATE film SET tittle = '%s' , duration = '%d', language ='%s' , description ='%s' + public function editFilm($id, $tittle, $duration, $language,$description,$img){ + $sql = sprintf( "UPDATE film SET tittle = '%s' , duration = '%d', language ='%s' , description ='%s', img ='%s' WHERE film.id = '%d';", - $tittle, $duration, $language, $description, $id); + $tittle, $duration, $language, $description, $img, $id); $resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database'); @@ -95,8 +95,8 @@ } //Create a new film Data Transfer Object. - public function loadFilm($id, $tittle, $duration, $language,$description){ - return new Film( $id, $tittle, $duration, $language,$description); + public function loadFilm($id, $tittle, $duration, $language,$description, $img){ + return new Film( $id, $tittle, $duration, $language,$description, $img); } }