From 13e0a508ff920ec1cedbaf10d0d173c8aa0dad3d Mon Sep 17 00:00:00 2001 From: Markines16 <80280295+Markines16@users.noreply.github.com> Date: Wed, 5 May 2021 16:55:00 +0200 Subject: [PATCH] hall y hall_dao update --- assets/php/common/hall.php | 14 +++++++++++++- assets/php/common/hall_dao.php | 27 +++++++++++++++++++++++---- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/assets/php/common/hall.php b/assets/php/common/hall.php index a9f638a..9580548 100644 --- a/assets/php/common/hall.php +++ b/assets/php/common/hall.php @@ -1,5 +1,5 @@ searchHall($hall['cinema'], $hall['number'])){ + $bd->createHall($hall['number'], $hall['cinema'], $hall['cols'], $hall['rows']); + return "Se ha creado la sala con exito"; + } else { + return "Esta sala ya existe"; + } + } else { return "Error al conectarse a la base de datos"; } + } + //Getters && Setters: public function setNumber($number){ $this->_number = $number; } public function getNumber(){ return $this->_number; } diff --git a/assets/php/common/hall_dao.php b/assets/php/common/hall_dao.php index f1276d2..da50159 100644 --- a/assets/php/common/hall_dao.php +++ b/assets/php/common/hall_dao.php @@ -1,5 +1,5 @@ mysqli, $sql) or die ('Error BD createhall'); + return $sql; } - + //Returns a query to get the halls data. public function getAllHalls($cinema){ $sql = sprintf( "SELECT * FROM hall WHERE @@ -39,7 +41,24 @@ return $hall; } - + + //Returns the count of the hall searched + public function searchHall($number, $cinema){ + + $sql = sprintf( "SELECT COUNT(*) FROM hall WHERE + idcinema = '%s' AND number = '%s'", + $cinema, $number); + $resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database'); + + $hall = mysqli_fetch_array($resul); + + mysqli_free_result($resul); + + return $hall[0]; + } + + + //Create a new Hall Data Transfer Object. public function loadHall($number, $idcinema, $numrows, $numcolumns){ return new Hall($number, $idcinema, $numrows, $numcolumns);