Comprobacion de si exite la pelicula en la base de datos
This commit is contained in:
parent
ab215853b9
commit
53238f6ef2
@ -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.
|
||||
@ -28,6 +34,8 @@
|
||||
|
||||
return $resul;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Returns a query to get All the films.
|
||||
public function allFilmData(){
|
||||
|
@ -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"){
|
||||
$bd->deleteFilm($id);
|
||||
$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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user