Add files via upload

This commit is contained in:
OscarRui 2021-05-07 19:06:12 +02:00 committed by GitHub
parent bed5c222ff
commit b635ce70a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 9 deletions

View File

@ -11,11 +11,12 @@
private $_total_seats;
//Constructor:
function __construct($number, $idcinema, $numRows, $numCol){
function __construct($number, $idcinema, $numRows, $numCol, $total_seats){
$this->_number = $number;
$this->_idcinema = $idcinema;
$this->_numRows = $numRows;
$this->_numCol = $numCol;
$this->_total_seats = $total_seats;
}
//Methods:
@ -38,6 +39,30 @@
} else { return "Error al conectarse a la base de datos"; }
}
public static function edit_hall($hall){
$bd = new HallDAO('complucine');
if($bd ){
if($bd->searchHall($hall)){
$bd->editHall($hall);
return "Se ha editado la sala con exito";
} else {
return "Esta sala no existe";
}
} else { return "Error al conectarse a la base de datos"; }
}
public static function delete_hall($hall){
$bd = new HallDAO('complucine');
if($bd ){
if($bd->searchHall($hall)){
$bd->deleteHall($hall);
return "Se ha eliminado la sala con exito";
} else {
return "Esta sala no existe";
}
} else { return "Error al conectarse a la base de datos"; }
}
//Getters && Setters:
public function setNumber($number){ $this->_number = $number; }
public function getNumber(){ return $this->_number; }
@ -51,6 +76,9 @@
public function setNumCol($numCol){ $this->_numCol = $numCol; }
public function getNumCol(){ return $this->_numCol; }
public function setTotalSeats($totalSeat){ $this->_total_seats = $totalSeat; }
public function getTotalSeats(){ return $this->_total_seats; }
}

View File

@ -37,7 +37,7 @@
$hall = null;
while($fila=mysqli_fetch_array($resul)){
$hall[] = $this->loadHall($fila["number"], $fila["idcinema"], $fila["numrows"], $fila["numcolumns"]);
$hall[] = $this->loadHall($fila["number"], $fila["idcinema"], $fila["numrows"], $fila["numcolumns"], $fila["total_seats"]);
}
mysqli_free_result($resul);
@ -63,17 +63,17 @@
//Create a new Hall Data Transfer Object.
public function loadHall($number, $idcinema, $numrows, $numcolumns){
return new Hall($number, $idcinema, $numrows, $numcolumns);
public function loadHall($number, $idcinema, $numrows, $numcolumns,$total_seats){
return new Hall($number, $idcinema, $numrows, $numcolumns,$total_seats);
}
//Edit Hall.
public function editHall($id, $idcinema, $numCol, $numRows){
public function editHall($hall){
$sql = sprintf( "UPDATE `hall`
SET `numrows` = '%i' , `numcolumns` = '%i'
SET `numrows` = '%d' , `numcolumns` = '%d' , `total_seats` = %d
WHERE `hall`.`number` = '%d' AND `hall`.`idcinema` = '%d';",
$numRows,$numCol,$id, $idcinema );
$hall['rows'], $hall['cols'], $hall['seats'], $hall['number'], $hall['cinema'] );
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
@ -81,9 +81,9 @@
}
//Delete Hall.
public function deleteHall($id, $idcinema){
public function deleteHall($hall){
$sql = sprintf( "DELETE FROM `hall` WHERE `hall`.`number` = '%d' AND `hall`.`idcinema` = '%d';",$id,$idcinema);
$sql = sprintf( "DELETE FROM `hall` WHERE `hall`.`number` = '%d' AND `hall`.`idcinema` = '%d';",$hall['number'], $hall['cinema']);
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');