Add files via upload

This commit is contained in:
Daniel Muñoz Garcia 2021-04-12 12:26:12 +02:00 committed by GitHub
parent 1e91584f47
commit 62fe03a7a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 65 additions and 50 deletions

View File

@ -1,47 +1,63 @@
<?php
require_once('../assets/php/dao.php');
include_once('film_dto.php');
class Film_DAO extends DAO {
//Constructor:
function __construct($bd_name){
parent::__construct($bd_name);
}
//Methods:
//Create a new Session.
public function createFilm($id, $tittle, $duration, $language){
$sql = sprintf( "INSERT INTO film( $id, $tittle, $duration, $language)
VALUES ( '%d', '%s', '%d', '%s')",
$id, $tittle, $duration, $language);
return $sql;
}
//Returns a query to get the film's data.
public function FilmData($id){
$sql = sprintf( "SELECT * FROM film WHERE id = '%d'", $id );
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
return $resul;
}
//Returns a query to get All the films.
public function allFilmData(){
$sql = sprintf( "SELECT * FROM film ");
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
return $resul;
}
//Create a new film Data Transfer Object.
public function loadFilm($id, $tittle, $duration, $language){
return new FilmDTO( $id, $tittle, $duration, $language);
}
}
?>
<?php
include_once('../assets/php/dao.php');
include_once('film_dto.php');
class FilmDAO extends DAO {
//Constructor:
function __construct($bd_name){
parent::__construct($bd_name);
}
//Methods:
//Create a new Session.
public function createFilm($id, $tittle, $duration, $language, $description){
$sql = sprintf( "INSERT INTO film( $id, $tittle, $duration, $language, $description)
VALUES ( '%d', '%s', '%d', '%s', '%d')",
$id, $tittle, $duration, $language, $description);
return $sql;
}
//Returns a query to get the film's data.
public function FilmData($id){
$sql = sprintf( "SELECT * FROM film WHERE id = '%d'", $id );
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
return $resul;
}
//Returns a query to get All the films.
public function allFilmData(){
$sql = sprintf( "SELECT * FROM film ");
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
while($fila=mysqli_fetch_array($resul)){
$films[] = $this->loadFilm($fila["id"], $fila["tittle"],$fila["duration"],$fila["language"],$fila["description"]);
}
return $films;
}
//Create a new film Data Transfer Object.
public function loadFilm($id, $tittle, $duration, $language, $description){
return new FilmDTO( $id, $tittle, $duration, $language, $description);
}
/*public function addFilm($films) {
$resul = mysqli_query($this->mysqli, $this->createFilm($film.getId(), $film.getTittle(), $film.getDuration(), $film.getLanguage(), $film.getDescription())) or die ('Error into query database');
return $resul;
}*/
//Returns a query to get all films tittles.
public function tittleFilmData(){
$sql = sprintf( "SELECT tittle FROM film ");
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
return $resul;
}
}
?>

View File

@ -1,7 +1,6 @@
<?php
include_once('film_dto_interface.php');
class Film_DTO implements FilmDTO {
class FilmDTO implements Film_DTO {
//Attributes:
private $_id; //Film ID.

View File

@ -1,5 +1,5 @@
<?php
interface FilmDTO {
interface Film_DTO {
public function setId($id);
public function getId();
public function setTittle($tittle);