From 11ab79854fc769ca7996fd75bc48f98928fde826 Mon Sep 17 00:00:00 2001 From: marian1010 <79144276+marian1010@users.noreply.github.com> Date: Tue, 13 Apr 2021 21:45:30 +0200 Subject: [PATCH] Update film_dao.php --- panel_admin/includes/film_dao.php | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/panel_admin/includes/film_dao.php b/panel_admin/includes/film_dao.php index e0bb97c..badde38 100644 --- a/panel_admin/includes/film_dao.php +++ b/panel_admin/includes/film_dao.php @@ -1,5 +1,5 @@ mysqli, $exist) ; + if($film.is_null() ||$film["language"]!=$language){ + $sql = sprintf( "INSERT INTO `film`( `id`, `tittle`, `duration`, `language`,`description`) + VALUES ( '%d', '%s', '%d', '%s','%s')", + $id, $tittle, $duration, $language,$description); $resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database'); - + }else{ + die ('Error into query database film already exist'); + } return $sql; } @@ -39,10 +43,8 @@ while($fila=mysqli_fetch_array($resul)){ $films[] = $this->loadFilm($fila["id"], $fila["tittle"], $fila["duration"], $fila["language"], $fila["description"]); } - $resul->free(); - - return $resul; + return $films; } //Returns a query to get all films tittles. @@ -89,8 +91,8 @@ } //Create a new film Data Transfer Object. - public function loadFilm($id, $tittle, $duration, $language){ - return new FilmDTO( $id, $tittle, $duration, $language); + public function loadFilm($id, $tittle, $duration, $language,$description){ + return new Film_DTO( $id, $tittle, $duration, $language,$description); } }