Add files via upload
This commit is contained in:
parent
76f5b6bcf7
commit
712f3ba5ce
@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
include_once('../assets/php/dao.php');
|
require_once($prefix.'assets/php/dao.php');
|
||||||
include_once('film_dto.php');
|
include_once('film_dto.php');
|
||||||
|
|
||||||
class FilmDAO extends DAO {
|
class Film_DAO extends DAO {
|
||||||
|
|
||||||
//Constructor:
|
//Constructor:
|
||||||
function __construct($bd_name){
|
function __construct($bd_name){
|
||||||
@ -12,13 +12,13 @@
|
|||||||
//Methods:
|
//Methods:
|
||||||
|
|
||||||
//Create a new Session.
|
//Create a new Session.
|
||||||
public function createFilm($id, $tittle, $duration, $language, $description){
|
public function createFilm($id, $tittle, $duration, $language){
|
||||||
|
|
||||||
$sql = sprintf( "INSERT INTO film(tittle, duration, language, description)
|
$sql = sprintf( "INSERT INTO film( $id, $tittle, $duration, $language)
|
||||||
VALUES ('%s', '%d', '%s', '%s')",
|
VALUES ( '%d', '%s', '%d', '%s')",
|
||||||
$tittle, $duration, $language, $description);
|
$id, $tittle, $duration, $language);
|
||||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
|
||||||
return $resul;
|
return $sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Returns a query to get the film's data.
|
//Returns a query to get the film's data.
|
||||||
@ -32,43 +32,11 @@
|
|||||||
//Returns a query to get All the films.
|
//Returns a query to get All the films.
|
||||||
public function allFilmData(){
|
public function allFilmData(){
|
||||||
$sql = sprintf( "SELECT * FROM film ");
|
$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;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public function deleteFilm($id){
|
|
||||||
|
|
||||||
$sql = sprintf( "DELETE FROM film WHERE film.id = '%d' ;",$id);
|
|
||||||
|
|
||||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||||
|
|
||||||
return $resul;
|
return $resul;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function editFilm($id, $tittle, $duration, $language,$description){
|
|
||||||
$sql = sprintf( "UPDATE film
|
|
||||||
SET tittle = '%s' , duration = '%d', language ='%s' , description ='%s'
|
|
||||||
WHERE film.id = '%d';",
|
|
||||||
$tittle,$duration,$language, $description,$id);
|
|
||||||
|
|
||||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
|
||||||
return $resul;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//Returns a query to get all films tittles.
|
//Returns a query to get all films tittles.
|
||||||
public function tittleFilmData(){
|
public function tittleFilmData(){
|
||||||
$sql = sprintf( "SELECT DISTINCT tittle FROM film ");
|
$sql = sprintf( "SELECT DISTINCT tittle FROM film ");
|
||||||
@ -77,6 +45,46 @@
|
|||||||
return $resul;
|
return $resul;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Returns a query to get all films descriptions.
|
||||||
|
public function descriptionFilmData(){
|
||||||
|
$sql = sprintf( "SELECT description FROM film ");
|
||||||
|
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||||
|
|
||||||
|
return $resul;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
//Deleted film by "id".
|
||||||
|
public function deleteFilm($id){
|
||||||
|
$sql = sprintf( "DELETE FROM film WHERE film.id = '%d' ;",$id);
|
||||||
|
|
||||||
|
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||||
|
|
||||||
|
return $resul;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function editFilm($id, $tittle, $duration, $language,$description){
|
||||||
|
$sql = sprintf( "UPDATE film SET tittle = '%s' , duration = '%d', language ='%s' , description ='%s'
|
||||||
|
WHERE film.id = '%d';",
|
||||||
|
$tittle, $duration, $language, $description, $id);
|
||||||
|
|
||||||
|
$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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
include_once('film_dto_interface.php');
|
include_once('film_dto_interface.php');
|
||||||
class FilmDTO implements Film_DTO {
|
|
||||||
|
class Film_DTO implements FilmDTO {
|
||||||
|
|
||||||
//Attributes:
|
//Attributes:
|
||||||
private $_id; //Film ID.
|
private $_id; //Film ID.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
interface Film_DTO {
|
interface FilmDTO {
|
||||||
public function setId($id);
|
public function setId($id);
|
||||||
public function getId();
|
public function getId();
|
||||||
public function setTittle($tittle);
|
public function setTittle($tittle);
|
||||||
|
Loading…
Reference in New Issue
Block a user