Add files via upload

This commit is contained in:
OscarRui 2021-04-08 18:00:08 +02:00 committed by GitHub
parent 31c54a5a0c
commit 2f4d5234ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 196 additions and 0 deletions

View File

@ -0,0 +1,39 @@
<?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)
VALUES ( '%s', '%s', '%i', '%i')",
$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);
}
}
?>

View File

@ -0,0 +1,37 @@
<?php
include_once('room_dto_interface.php');
class RoomDTO implements RoomsDTO {
//Attributes:
private $_id; //Room Id.
private $_idcinema; //Cinema Id
private $_numCol; //Num columns.
private $_numRows; //Num rows.
//Constructor:
function __construct($id, $idcinema, $numCol, $numRows){
$this->_id = $id;
$this->_idcinema = $idcinema;
$this->_numCol = $numCol;
$this->_numRows = $numRows;
}
//Methods:
//Getters && Setters:
public function setId($id){ $this->_id = $id; }
public function getId(){ return $this->_id; }
public function setIdcinema($idcinema){ $this->_idcinema = $idcinema; }
public function getIdcinema(){ return $this->_idcinema; }
public function setNumCol($numCol){ $this->_numCol = $numCol; }
public function getNumCol(){ return $this->_numCol; }
public function setNumRows($numRows){ $this->_numRows = $numRows; }
public function getNumRows(){ return $this->_numRows; }
}
?>

View File

@ -0,0 +1,12 @@
<?php
interface RoomsDTO {
public function setId($id);
public function getId();
public function setIdcinema($idcinema);
public function getIdcinema();
public function setNumCol($numCol);
public function getNumCol();
public function setNumRows($numRows);
public function getNumRows();
}
?>

View File

@ -0,0 +1,39 @@
<?php
require_once('../assets/php/dao.php');
include_once('session_dto.php');
class SessionDAO extends DAO {
//Constructor:
function __construct($bd_name){
parent::__construct($bd_name);
}
//Methods:
//Create a new Session.
public function createSession($id, $idfilm, $idhall, $date, $startTime, $seatPrice, $format){
$sql = sprintf( "INSERT INTO sessions( $id, $idfilm, $idhall, $date, $startTime, $seatPrice, $format)
VALUES ( '%s', '%s', '%s', '%date', '%time', '%d', '%s')",
$id, $idfilm, $idhall, $date, $startTime, $seatPrice, $format );
return $sql;
}
//Returns a query to get the session's data.
public function sessionData($id){
$sql = sprintf( "SELECT * FROM sessions WHERE id = '%d'", $id );
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
return $resul;
}
//Create a new Session Data Transfer Object.
public function loadSession( $id, $idfilm, $idhall, $date, $startTime, $seatPrice, $format){
return new SessionDTO( $id, $idfilm, $idhall, $date, $startTime, $seatPrice, $format);
}
}
?>

View File

@ -0,0 +1,51 @@
<?php
include_once('session_dto_interface.php');
class SessionDTO implements SessionsDTO {
//Attributes:
private $_id; //Session Id.
private $_idfilm; //Film Id
private $_idhall //Hall id
private $_date; //Session date.
private $_startTime; //Session start time.
private $_seatPrice; //Seat price.
private $_format; //Type of film: 3D | 4D | normal | subtitle | mute.
//Constructor:
function __construct($id, $idfilm, $idhall, $date, $startTime, $seatPrice, $format){
$this->_id = $id;
$this->_idfilm = $idfilm;
$this->_idhall = $idhall;
$this->_date = $date;
$this->_startTime = $startTime;
$this->_seatPrice = $seatPrice;
$this->_format = $format;
}
//Methods:
//Getters && Setters:
public function setId($id){ $this->_id = $id; }
public function getId(){ return $this->_id; }
public function setIdfilm($idfilm){ $this->_idfilm = $idfilm; }
public function getIdfilm(){ return $this->_idfilm; }
public function setIdhall($film){ $this->_idhall = $idhall; }
public function getIdhall(){ return $this->_idhall; }
public function setDate($date){ $this->_date = $date; }
public function getDate(){ return $this->_date; }
public function setStartTime($startTime){ $this->_startTime = $startTime; }
public function getStartTime(){ return $this->_startTime; }
public function setSeatPrice($seatPrice){ $this->_seatPrice = $seatPrice; }
public function getSeatPrice(){ return $this->_seatPrice; }
public function setFormat($format){ $this->_format = $format; }
public function getFormat(){ return $this->_format; }
}
?>

View File

@ -0,0 +1,18 @@
<?php
interface SessionsDTO {
public function setId($id);
public function getId();
public function setIdfilm($idfilm);
public function getIdfilm();
public function setIdhall($film);
public function getIdhall();
public function setDate($date);
public function getDate();
public function setStartTime($startTime);
public function getStartTime();
public function setSeatPrice($seatPrice);
public function getSeatPrice();
public function setFormat($format);
public function getFormat();
}
?>