2021-04-08 18:00:08 +02:00
|
|
|
<?php
|
|
|
|
require_once('../assets/php/dao.php');
|
|
|
|
include_once('room_dto.php');
|
|
|
|
|
|
|
|
class RoomDAO extends DAO {
|
|
|
|
|
|
|
|
//Constructor:
|
|
|
|
function __construct($bd_name){
|
|
|
|
parent::__construct($bd_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
//Methods:
|
|
|
|
|
|
|
|
//Create a new Room.
|
|
|
|
public function createRoom($id, $idcinema, $numCol, $numRows){
|
|
|
|
|
|
|
|
$sql = sprintf( "INSERT INTO rooms( id, idcinema, numCol, numRows)
|
2021-04-11 19:08:22 +02:00
|
|
|
VALUES ( '%d', '%d', '%i', '%i')",
|
2021-04-08 18:00:08 +02:00
|
|
|
$id, $idcinema, $numCol, $numRows );
|
|
|
|
|
|
|
|
return $sql;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Returns a query to get the room's data.
|
|
|
|
public function roomData($id){
|
|
|
|
$sql = sprintf( "SELECT * FROM rooms WHERE id = '%d'", $id );
|
|
|
|
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
|
|
|
|
|
|
|
return $resul;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Create a new Room Data Transfer Object.
|
|
|
|
public function loadRoom($id, $idcinema, $numCol, $numRows){
|
|
|
|
return new RoomDTO($id, $idcinema, $numCol, $numRows);
|
|
|
|
}
|
|
|
|
|
2021-04-11 19:08:22 +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;
|
|
|
|
}
|
|
|
|
|
2021-04-08 18:00:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|