2021-04-11 19:54:18 +02:00
|
|
|
<?php
|
|
|
|
require_once('../assets/php/dao.php');
|
|
|
|
include_once('hall_dto.php');
|
|
|
|
|
|
|
|
class HallDAO extends DAO {
|
|
|
|
|
|
|
|
//Constructor:
|
|
|
|
function __construct($bd_name){
|
|
|
|
parent::__construct($bd_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
//Methods:
|
|
|
|
|
|
|
|
//Create a new Hall.
|
|
|
|
public function createHall($number, $idcinema, $numCol, $numRows){
|
|
|
|
|
|
|
|
$sql = sprintf( "INSERT INTO `hall`( `number`, `idcinema`, `numrows`, `numcolumns`)
|
|
|
|
VALUES ( '%d', '%d', '%i', '%i')",
|
|
|
|
$number, $idcinema, $numRows, $numCol );
|
|
|
|
|
|
|
|
return $sql;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Returns a query to get the halls data.
|
2021-04-13 21:15:28 +02:00
|
|
|
public function getAllHalls($cinema){
|
|
|
|
$sql = sprintf( "SELECT * FROM hall WHERE
|
|
|
|
idcinema = '%s'",
|
|
|
|
$cinema);
|
|
|
|
|
2021-04-11 19:54:18 +02:00
|
|
|
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
2021-04-13 21:15:28 +02:00
|
|
|
|
|
|
|
$hall = null;
|
|
|
|
|
|
|
|
while($fila=mysqli_fetch_array($resul)){
|
|
|
|
$hall[] = $this->loadHall($fila["number"], $fila["idcinema"], $fila["numrows"], $fila["numcolumns"]);
|
|
|
|
}
|
|
|
|
|
|
|
|
mysqli_free_result($resul);
|
|
|
|
|
|
|
|
return $hall;
|
2021-04-11 19:54:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//Create a new Hall Data Transfer Object.
|
2021-04-13 21:15:28 +02:00
|
|
|
public function loadHall($number, $idcinema, $numrows, $numcolumns){
|
|
|
|
return new HallDTO($number, $idcinema, $numrows, $numcolumns);
|
2021-04-11 19:54:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//Edit Hall.
|
|
|
|
public function editHall($id, $idcinema, $numCol, $numRows){
|
|
|
|
|
|
|
|
$sql = sprintf( "UPDATE `hall`
|
|
|
|
SET `numrows` = '%i' , `numcolumns` = '%i'
|
|
|
|
WHERE `hall`.`number` = '%d' AND `hall`.`idcinema` = '%d';",
|
|
|
|
$numRows,$numCol,$id, $idcinema );
|
|
|
|
|
|
|
|
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
|
|
|
|
|
|
|
return $resul;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Delete Hall.
|
|
|
|
public function deleteHall($id, $idcinema){
|
|
|
|
|
|
|
|
$sql = sprintf( "DELETE FROM `hall` WHERE `hall`.`number` = '%d' AND `hall`.`idcinema` = '%d';",$id,$idcinema);
|
|
|
|
|
|
|
|
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
|
|
|
|
|
|
|
return $resul;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|