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);