SW/panel_manager/includes/session_dao.php
Markines16 a7575ba942
Muchas conexiones con la base de datos.
Ahora se pueden añadir sesiones (para una sala, cine y fecha predeterminada en el codigo). El "escoger" la pelicula es simplemente meter el id de la pelicula en cuestion.
La lista de sesiones en la vista de las sesiones hace recibe un array desde la base de datos (para una sala,cine y fecha predeterminada en el codigo). Lo que muestra la tabla tambien es solo la id de la pelicula.
2021-04-10 20:54:56 +02:00

60 lines
1.9 KiB
PHP

<?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, $idcinema, $date, $startTime, $seatPrice, $format){
$sql = sprintf( "INSERT INTO `session` (`id`, `idfilm`, `idhall`, `idcinema`, `date`, `start_time`, `seat_price`, `format`)
VALUES ('%d', '%d', '%d', '%d', '%s', '%s', '%d', '%s')",
$id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format);
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
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;
}
//Returns a query to check if the session in this cinema, hall and scheudle exists.
public function selectSession($cinema, $hall, $start, $date){
if($start == null){
$sql = sprintf( "SELECT * FROM session WHERE
idcinema = '%s' AND idhall = '%s' AND date = '%s'",
$cinema, $hall, $date);
}else{
$sql = sprintf( "SELECT * FROM session WHERE
idcinema = '%s' AND idhall = '%s' AND date = '%s' AND start_time = '%s'",
$cinema, $hall, $date, $start);
}
$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);
}
}
?>