Add files via upload

This commit is contained in:
OscarRui 2021-04-11 19:54:18 +02:00 committed by GitHub
parent 42d084ec5a
commit 68860539da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 113 additions and 0 deletions

View File

@ -0,0 +1,64 @@
<?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.
public function hallData($id,$idcinema){
$sql = sprintf( "SELECT * 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;
}
//Create a new Hall Data Transfer Object.
public function loadHall($id, $idcinema, $numCol, $numRows){
return new HallDTO($id, $idcinema, $numCol, $numRows);
}
//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;
}
}
?>

View File

@ -0,0 +1,37 @@
<?php
include_once('hall_dto_interface.php');
class HallDTO implements HallsDTO {
//Attributes:
private $_number; //Room number.
private $_idcinema; //Cinema Id
private $_numCol; //Num columns.
private $_numRows; //Num rows.
//Constructor:
function __construct($number, $idcinema, $numCol, $numRows){
$this->_number = $number;
$this->_idcinema = $idcinema;
$this->_numCol = $numCol;
$this->_numRows = $numRows;
}
//Methods:
//Getters && Setters:
public function setNumber($number){ $this->_number = $number; }
public function getNumber(){ return $this->_number; }
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 HallsDTO {
public function setNumber($number);
public function getNumber();
public function setIdcinema($idcinema);
public function getIdcinema();
public function setNumCol($numCol);
public function getNumCol();
public function setNumRows($numRows);
public function getNumRows();
}
?>