Comprobacion de si exite la pelicula en la base de datos

This commit is contained in:
marian1010 2021-04-14 10:29:27 +02:00
parent ab215853b9
commit 53238f6ef2
2 changed files with 31 additions and 5 deletions

View File

@ -18,7 +18,13 @@
$id, $tittle, $duration, $language,$description);
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
return $sql;
return $resul;
}
//Returns
public function GetFilm($tittle,$language){
$sql = sprintf( "SELECT * FROM film WHERE film.tittle = '%s'AND film.language='%s'", $tittle,$language );
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
return $resul;
}
//Returns a query to get the film's data.
@ -29,6 +35,8 @@
return $resul;
}
//Returns a query to get All the films.
public function allFilmData(){
$sql = sprintf( "SELECT * FROM film ");

View File

@ -46,7 +46,7 @@ class FormFilm extends Form {
}
//Process form:
public function processesForm($id,$title,$duration,$languaje,$description, $option) {
public function processesForm($id,$tittle,$duration,$language,$description, $option) {
$this->correct = true;
$this->option = $option;
@ -56,11 +56,29 @@ class FormFilm extends Form {
if($bd ){
if($option == "new"){
//Primero comprobar si existe una pelicula con el mismo titulo e idioma
$bd->createFilm(null, $title,$duration,$languaje,$description);
$exist = $bd-> GetFilm($tittle,$language);
if( mysqli_num_rows($exist) != 0){
$this->correct =false;
}
else{
$bd->createFilm(null, $tittle,$duration,$language,$description);
}
} else if ($option == "del"){
$exist = $bd-> FilmData($id);
if( mysqli_num_rows($exist) != 0){
$bd->deleteFilm($id);
}
else{
$this->correct =false;
}
} else if ($option == "edit"){
$bd->editFilm($id,$title,$duration,$languaje,$description);
$exist = $bd-> FilmData($id);
if( mysqli_num_rows($exist) != 0){
$bd->editFilm($id,$tittle,$duration,$language,$description);
}
else{
$this->correct =false;
}
} else if($this->option == "show") {
$this->array = $bd->allFilmData();
}