Add files via upload
This commit is contained in:
parent
0494c611b6
commit
68c117d9dc
@ -28,7 +28,16 @@
|
|||||||
public static function getListSessions($hall,$cinema,$date){
|
public static function getListSessions($hall,$cinema,$date){
|
||||||
$bd = new SessionDAO('complucine');
|
$bd = new SessionDAO('complucine');
|
||||||
if($bd ) {
|
if($bd ) {
|
||||||
return $bd->getAllSessions($hall, $cinema, $date);
|
if($date)
|
||||||
|
return $bd->getAllSessions($hall, $cinema, $date, null);
|
||||||
|
else
|
||||||
|
return $bd->getAllSessions($hall, $cinema, null, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static function getListSessionsBetween2Dates($hall,$cinema,$start,$end){
|
||||||
|
$bd = new SessionDAO('complucine');
|
||||||
|
if($bd ) {
|
||||||
|
return $bd->getAllSessions($hall, $cinema, $start, $end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,17 +62,36 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Returns a query to get all the session's data.
|
//Returns a query to get all the session's data.
|
||||||
public function getAllSessions($hall, $cinema, $date){
|
public function getAllSessions($hall, $cinema, $date, $end){
|
||||||
$date = date('Y-m-d', strtotime( $date ) );
|
if($end){
|
||||||
|
|
||||||
|
$date = $date->format("Y-m-d");
|
||||||
|
$end = $end->format("Y-m-d");
|
||||||
|
|
||||||
|
// su output es date: 2021-05-30 end: 2021-07-11
|
||||||
|
$sql = sprintf( "SELECT * FROM session WHERE
|
||||||
|
idcinema = '%s' AND idhall = '%s' AND date BETWEEN '%s' AND '%s' ORDER BY start_time ASC;",
|
||||||
|
$cinema, $hall, $date, $end);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if($date && !$end){
|
||||||
|
$date = date('Y-m-d', strtotime( $date ) );
|
||||||
|
|
||||||
|
$sql = sprintf( "SELECT * FROM session WHERE
|
||||||
|
idcinema = '%s' AND idhall = '%s' AND date = '%s' ORDER BY start_time ASC;",
|
||||||
|
$cinema, $hall, $date);
|
||||||
|
}else{
|
||||||
|
$sql = sprintf( "SELECT * FROM session WHERE
|
||||||
|
idcinema = '%s' AND idhall = '%s' ORDER BY start_time ASC;",
|
||||||
|
$cinema, $hall);
|
||||||
|
}
|
||||||
|
|
||||||
$sql = sprintf( "SELECT * FROM session WHERE
|
|
||||||
idcinema = '%s' AND idhall = '%s' AND date = '%s' ORDER BY start_time ASC;",
|
|
||||||
$cinema, $hall, $date);
|
|
||||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||||
|
|
||||||
$sessions = null;
|
$sessions = null;
|
||||||
|
|
||||||
while($fila=mysqli_fetch_array($resul)){
|
while($fila=$resul->fetch_assoc()){
|
||||||
$sessions[] = $this->loadSession($fila["id"], $fila["idfilm"], $fila["idhall"], $fila["idcinema"], $fila["date"], $fila["start_time"], $fila["seat_price"], $fila["format"], $fila["seats_full"]);
|
$sessions[] = $this->loadSession($fila["id"], $fila["idfilm"], $fila["idhall"], $fila["idcinema"], $fila["date"], $fila["start_time"], $fila["seat_price"], $fila["format"], $fila["seats_full"]);
|
||||||
}
|
}
|
||||||
mysqli_free_result($resul);
|
mysqli_free_result($resul);
|
||||||
|
Loading…
Reference in New Issue
Block a user