Lo vuelvo a subir

This commit is contained in:
marian1010 2021-04-14 12:39:32 +02:00
parent 8ae58acce4
commit 1c283b6326
2 changed files with 38 additions and 12 deletions

View File

@ -18,7 +18,13 @@
$id, $tittle, $duration, $language,$description); $id, $tittle, $duration, $language,$description);
$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 $sql; return $resul;
}
//Returns a film data .
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. //Returns a query to get the film's data.

View File

@ -46,8 +46,8 @@ class FormFilm extends Form {
} }
//Process 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->correct = true;
$this->option = $option; $this->option = $option;
//Habria que validar todo para que encaje en la base de datos //Habria que validar todo para que encaje en la base de datos
@ -56,18 +56,38 @@ class FormFilm extends Form {
if($bd ){ if($bd ){
if($option == "new"){ if($option == "new"){
//Primero comprobar si existe una pelicula con el mismo titulo e idioma //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"){ } else if ($option == "del"){
$bd->deleteFilm($id); //Primero comprobar si existe una pelicula con el mismo id
$exist = $bd-> FilmData($id);
if( mysqli_num_rows($exist) != 0){
$bd->deleteFilm($id);
}
else{
$this->correct =false;
}
} else if ($option == "edit"){ } else if ($option == "edit"){
$bd->editFilm($id,$title,$duration,$languaje,$description); //Primero comprobar si existe una pelicula con el mismo id
$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") { } else if($this->option == "show") {
$this->array = $bd->allFilmData(); $this->array = $bd->allFilmData();
} }
} else {$this->correct = false;} } else {$this->correct = false;}
}
}
}
} }
?> ?>