diff --git a/panel_admin/includes/film_dao.php b/panel_admin/includes/film_dao.php index e9be226..685237d 100644 --- a/panel_admin/includes/film_dao.php +++ b/panel_admin/includes/film_dao.php @@ -1,82 +1,90 @@ -mysqli, $sql) or die ('Error into query database'); - return $resul; - } - - //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; - }*/ - - 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; - } - - - //Returns a query to get all films tittles. - public function tittleFilmData(){ - $sql = sprintf( "SELECT DISTINCT tittle FROM film "); - $resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database'); - - return $resul; - } - - } - -?> \ No newline at end of file +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; + } + + //Returns a query to get all films tittles. + public function tittleFilmData(){ + $sql = sprintf( "SELECT DISTINCT tittle FROM film "); + $resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database'); + + 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); + } + + } + +?> diff --git a/panel_admin/includes/film_dto.php b/panel_admin/includes/film_dto.php index 55840bd..3b24897 100644 --- a/panel_admin/includes/film_dto.php +++ b/panel_admin/includes/film_dto.php @@ -1,13 +1,14 @@