Add functions

This commit is contained in:
Daniel Muñoz Garcia 2021-05-26 11:47:10 +02:00 committed by GitHub
parent 113a6413a8
commit 90f233fca9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 9 deletions

View File

@ -111,6 +111,17 @@
return $resul;
}
//Edit a film.
public function editFilmNoImg($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;
}
//Get cinemas associated with a movie.
public function getCinemas($id){
include_once('cinema_dao.php');

View File

@ -8,14 +8,16 @@
private $_description; //Promotion description.
private $_code; //Promotion code.
private $_active; //Promotion is active?
private $_img;
//Constructor:
function __construct($id, $tittle, $description, $code, $active){
function __construct($id, $tittle, $description, $code, $active, $img){
$this->_id = $id;
$this->_tittle = $tittle;
$this->_description = $description;
$this->_code = $code;
$this->_active = $active;
$this->_img= $img;
}
//Methods:
@ -31,6 +33,8 @@
public function getCode(){return $this->_code;}
public function setActive($active){ $this->_active = $active;}
public function getActive(){return $this->_active;}
public function setImg($img){ $this->_img = $img;}
public function getImg(){return $this->_img;}
}
?>

View File

@ -11,10 +11,10 @@
//Methods:
//Create a new Session.
public function createPromotion($id, $tittle, $description, $code, $active){
$sql = sprintf( "INSERT INTO `promotion`( `id`, `tittle`, `description`, `code`, `active`)
VALUES ( '%d', '%s', '%s', '%s', '%s')",
$id, $tittle, $description, $code, $active);
public function createPromotion($id, $tittle, $description, $code, $active, $img){
$sql = sprintf( "INSERT INTO `promotion`( `id`, `tittle`, `description`, `code`, `active`, `img`)
VALUES ( '%d', '%s', '%s', '%s', '%s', '%s')",
$id, $tittle, $description, $code, $active, $img);
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
return $resul;
@ -27,7 +27,7 @@
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
while($fila=$resul->fetch_assoc()){
$promotions[] = $this->loadPromotion($fila["id"], $fila["tittle"], $fila["description"], $fila["code"], $fila["active"]);
$promotions[] = $this->loadPromotion($fila["id"], $fila["tittle"], $fila["description"], $fila["code"], $fila["active"], null);
}
$resul->free();
return $promotions;
@ -57,7 +57,17 @@
}
//Edit a film.
public function editPromotion($id, $tittle, $description, $code, $active){
public function editPromotion($id, $tittle, $description, $code, $active, $img){
$sql = sprintf( "UPDATE promotion SET tittle = '%s' , description = '%s', code ='%s' , active ='%s', img = '%s'
WHERE promotion.id = '%d';",
$tittle, $description, $code, $active, $img, $id);
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
return $resul;
}
public function editPromotionNoImg($id, $tittle, $description, $code, $active){
$sql = sprintf( "UPDATE promotion SET tittle = '%s' , description = '%s', code ='%s' , active ='%s'
WHERE promotion.id = '%d';",
$tittle, $description, $code, $active, $id);
@ -68,8 +78,8 @@
}
//Create a new film Data Transfer Object.
public function loadPromotion($id, $tittle, $description, $code, $active){
return new Promotion($id, $tittle, $description, $code, $active);
public function loadPromotion($id, $tittle, $description, $code, $active, $img){
return new Promotion($id, $tittle, $description, $code, $active, $img);
}
}