From 4d1eb61a1e92e6cf1e5e8879a0401e8dd23a259b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mu=C3=B1oz=20Garcia?= <73303506+danimu03@users.noreply.github.com> Date: Wed, 26 May 2021 09:56:54 +0200 Subject: [PATCH] Add functions --- assets/php/includes/cinema_dao.php | 15 +++++++++++++-- assets/php/includes/film_dao.php | 8 ++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/assets/php/includes/cinema_dao.php b/assets/php/includes/cinema_dao.php index 0660562..ee0dd92 100644 --- a/assets/php/includes/cinema_dao.php +++ b/assets/php/includes/cinema_dao.php @@ -42,10 +42,13 @@ //Returns a film data . public function cinemaData($id){ - $sql = sprintf( "SELECT * FROM cinema WHERE cinema.id = '%d'", $id); + $id = $this->mysqli->real_escape_string($id); + + $sql = sprintf( "SELECT * FROM cinema WHERE id = '%d'", $id ); $resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database'); - $cinema = null; + $resul->data_seek(0); + $film = null; while($fila=$resul->fetch_assoc()){ $cinema = $this->loadCinema($fila["id"], $fila["name"], $fila["direction"], $fila["phone"]); } @@ -54,6 +57,14 @@ return $cinema; } + public function existCinema($id){ + $id = $this->mysqli->real_escape_string($id); + + $sql = sprintf( "SELECT * FROM cinema WHERE id = '%d'", $id ); + $resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database'); + return $resul; + } + //Deleted film by "id". public function deleteCinema($id){ $sql = sprintf( "DELETE FROM cinema WHERE cinema.id = '%d' ;",$id); diff --git a/assets/php/includes/film_dao.php b/assets/php/includes/film_dao.php index 9b4f77c..d4524f3 100644 --- a/assets/php/includes/film_dao.php +++ b/assets/php/includes/film_dao.php @@ -46,6 +46,14 @@ return $film; } + + public function existFilm($id){ + $id = $this->mysqli->real_escape_string($id); + + $sql = sprintf( "SELECT * FROM film WHERE id = '%d'", $id ); + $resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database'); + return $resul; + } //Returns a query to get All the films. public function allFilmData(){