From 79ae1b24db98124ffe65a652a90dc997fd4efc7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mu=C3=B1oz=20Garcia?= <73303506+danimu03@users.noreply.github.com> Date: Thu, 15 Apr 2021 10:18:50 +0200 Subject: [PATCH] Add files via upload --- panel_admin/includes/film_dao.php | 7 +------ panel_admin/includes/formFilm.php | 20 +++++++++++++++----- panel_admin/index.php | 15 +++++---------- panel_admin/manage_films.php | 4 ++-- panel_admin/panelAdmin.php | 27 ++++++++++++++++++--------- panel_admin/updateFilm.php | 7 +++---- 6 files changed, 44 insertions(+), 36 deletions(-) diff --git a/panel_admin/includes/film_dao.php b/panel_admin/includes/film_dao.php index 3f34771..07c41c6 100644 --- a/panel_admin/includes/film_dao.php +++ b/panel_admin/includes/film_dao.php @@ -39,12 +39,7 @@ public function allFilmData(){ $sql = sprintf( "SELECT * FROM film "); $resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database'); - - while($fila=mysqli_fetch_array($resul)){ - $films[] = $this->loadFilm($fila["id"], $fila["tittle"], $fila["duration"], $fila["language"], $fila["description"]); - } - $resul->free(); - return $films; + return $resul; } //Returns a query to get all films tittles. diff --git a/panel_admin/includes/formFilm.php b/panel_admin/includes/formFilm.php index 37caafb..f14bd0b 100644 --- a/panel_admin/includes/formFilm.php +++ b/panel_admin/includes/formFilm.php @@ -1,6 +1,7 @@ correct =false; } else{ - $bd->createFilm(null, $tittle,$duration,$language,$description); + $resul=$bd->createFilm(null, $tittle,$duration,$language,$description); + $resul->free(); } + $exist->free(); } else{ $this->correct =false; @@ -72,7 +75,7 @@ class FormFilm extends Form { } else if ($option == "del"){ //Primero comprobar si existe una pelicula con el mismo id $exist = $bd-> FilmData($id); - if( mysqli_num_rows($exist) != 0){ + if( mysqli_num_rows($exist) == 1){ $bd->deleteFilm($id); } else{ @@ -83,21 +86,28 @@ class FormFilm extends Form { if(!empty($tittle)&&$duration>0&&!empty($language)&&!empty($description)){ //comprobar si existe una pelicula con el mismo id $exist = $bd-> FilmData($id); - if( mysqli_num_rows($exist) != 0){ - $bd->editFilm($id,$tittle,$duration,$language,$description); + if( mysqli_num_rows($exist) == 1){ + $resul = $bd->editFilm($id,$tittle,$duration,$language,$description); + $resul->free(); } else{ $this->correct =false; } + $exist->free(); } else{ $this->correct =false; } } else if($this->option == "show") { - $this->array = $bd->allFilmData(); + $resul = $bd->allFilmData(); + while($fila=mysqli_fetch_assoc($resul)){ + $this->array = new FilmDTO($fila["id"], $fila["tittle"], $fila["duration"], $fila["language"], $fila["description"]); + } + $resul->free(); } else {$this->correct = false;} } + $bd->__destruct(); } } diff --git a/panel_admin/index.php b/panel_admin/index.php index 5e79460..a152f5c 100644 --- a/panel_admin/index.php +++ b/panel_admin/index.php @@ -41,23 +41,18 @@
diff --git a/panel_admin/manage_films.php b/panel_admin/manage_films.php index 7b8340d..079dcc8 100644 --- a/panel_admin/manage_films.php +++ b/panel_admin/manage_films.php @@ -1,6 +1,6 @@ state = $panel; + $this->login= $login; } function showPanel() { - switch($this->state) { - case 'uf': require('updateFilm.php');break; - case 'mc': require('manage_cinemas.php'); break; - case 'mf': require('manage_films.php'); break; - case 'md': require('manage_discounts.php'); break; - case 'mm': require('manage_managers.php'); break; - default: echo "