2021-05-06 23:23:34 +02:00
|
|
|
<?php
|
|
|
|
include_once('seat.php');
|
|
|
|
|
|
|
|
class SeatDAO extends DAO {
|
|
|
|
|
|
|
|
//Constructor:
|
|
|
|
function __construct($bd_name){
|
|
|
|
parent::__construct($bd_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
//Methods:
|
|
|
|
|
|
|
|
//Create a new Hall.
|
2021-05-10 16:46:18 +02:00
|
|
|
public function createSeat($hall, $cinema, $row, $col, $state){
|
2021-05-06 23:23:34 +02:00
|
|
|
|
|
|
|
$sql = sprintf( "INSERT INTO `seat`( `idhall`, `idcinema`, `numrow`, `numcolum`, `active`)
|
|
|
|
VALUES ( '%d', '%d', '%d', '%d', '%d')",
|
2021-05-10 16:46:18 +02:00
|
|
|
$hall, $cinema, $row, $col, $state);
|
2021-05-06 23:23:34 +02:00
|
|
|
|
|
|
|
$resul = mysqli_query($this->mysqli, $sql) or die ('Error BD createSeat');
|
|
|
|
|
|
|
|
return $sql;
|
|
|
|
}
|
2021-05-10 16:46:18 +02:00
|
|
|
|
|
|
|
public function getAllSeats($number, $cinema){
|
|
|
|
|
|
|
|
$sql = sprintf( "SELECT * FROM seat WHERE
|
|
|
|
idhall = '%s' AND idcinema = '%s'",
|
|
|
|
$number, $cinema);
|
|
|
|
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
|
|
|
|
|
|
|
$seat_map = null;
|
|
|
|
while($fila=mysqli_fetch_array($resul)){
|
|
|
|
$seat_map[] = $this->loadSeat($fila["idhall"], $fila["idcinema"], $fila["numrow"], $fila["numcolum"], $fila["active"]);
|
|
|
|
}
|
|
|
|
|
|
|
|
mysqli_free_result($resul);
|
|
|
|
|
|
|
|
return $seat_map;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function deletemapSeats($hall, $cinema){
|
|
|
|
$sql = sprintf( "DELETE FROM `seat` WHERE
|
|
|
|
idcinema = '%s' AND idhall = '%s'",
|
|
|
|
$cinema, $hall);
|
|
|
|
|
|
|
|
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
|
|
|
|
|
|
|
return $resul;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function loadSeat($idhall, $idcinema, $numRow, $numCol, $state){
|
|
|
|
return new Seat($idhall, $idcinema, $numRow, $numCol, $state);
|
|
|
|
}
|
|
|
|
|
2021-05-06 23:23:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|