本文整理汇总了PHP中Movie::getDirector方法的典型用法代码示例。如果您正苦于以下问题:PHP Movie::getDirector方法的具体用法?PHP Movie::getDirector怎么用?PHP Movie::getDirector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Movie
的用法示例。
在下文中一共展示了Movie::getDirector方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: duplicateMovie
public function duplicateMovie($id, $idUser)
{
$movie = null;
$resultats = $this->bdd->prepare("SELECT * FROM movie WHERE mov_id=?;");
$resultats->execute(array($id));
$resultats->setFetchMode(PDO::FETCH_OBJ);
while ($result = $resultats->fetch()) {
$movie = new Movie($result->mov_id, $result->mov_user, $result->mov_title, $result->mov_description_short, $result->mov_description_long, $result->mov_director, $result->mov_year, $result->mov_image, $result->mov_cat);
}
$movie->setUser($idUser);
$req2 = $this->bdd->prepare("INSERT INTO movie (mov_title, mov_user,mov_description_short, mov_description_long, mov_director, mov_year, mov_image, mov_cat) VALUES (:titre, :utilisateur, :resume, :synopsis, :realisateur, :annee, :affiche, :categorie)");
$result2 = $req2->execute(array("titre" => htmlspecialchars($movie->getTitle()), "utilisateur" => htmlspecialchars($movie->getUser()), "resume" => htmlspecialchars($movie->getDescriptionShort()), "synopsis" => htmlspecialchars($movie->getDescriptionLong()), "realisateur" => htmlspecialchars($movie->getDirector()), "annee" => htmlspecialchars($movie->getYear()), "affiche" => htmlspecialchars($movie->getImage()), "categorie" => htmlspecialchars($movie->getCategory())));
$movie->setId($this->bdd->lastInsertId());
return $movie;
}
示例2: updateMovie
public function updateMovie(Movie $movie)
{
$this->connect();
// disable auto commit, so that we can roll back bridge table deletes if
// the transaction fails in the second portion of the query
mysqli_autocommit($this->link, FALSE);
// first, we delete all records in the actor bridge table for the movie
$sqlDelete = "DELETE FROM actor WHERE movie_id = " . $movie->getId();
try {
if (mysqli_query($this->link, $sqlDelete)) {
// now that the bridge table is cleared out, update the movie
$movieId = $movie->getId();
$directorId = $movie->getDirector()->getId();
$title = "'" . mysqli_real_escape_string($this->link, $movie->getTitle()) . "'";
$releaseDate = "'" . $movie->getReleaseDate() . "'";
$synopsis = "'" . mysqli_real_escape_string($this->link, $movie->getSynopsis()) . "'";
$sqlUpdate = "UPDATE movie " . "SET director_id = {$directorId}, " . "title = {$title}, " . "release_date = {$releaseDate}, " . "submit_date = CURDATE(), " . "synopsis = {$synopsis} " . "WHERE id = {$movieId}";
if (mysqli_query($this->link, $sqlUpdate)) {
// alright, movie table is updated, now to re-enter the new
// actor list into the bridge table.
$callback = function ($person) use($movieId) {
if ($person instanceof Person) {
$personId = $person->getId();
return "({$movieId}, {$personId})";
} else {
return "";
}
};
$bridgePairs = array_map($callback, $movie->getActors());
$values = implode(", ", $bridgePairs);
$bridgeSql = "INSERT INTO actor (movie_id, people_id) VALUES {$values}";
$result = mysqli_query($this->link, $bridgeSql);
if ($result) {
// ok, movie is update, and bridge table too
// now we can safely commit
mysqli_commit($this->link);
$this->disconnect();
return TRUE;
}
} else {
// uh oh, something went wrong, roll back and abort!
mysqli_rollback($this->link);
$this->disconnect();
return FALSE;
}
} else {
return FALSE;
}
} catch (Exception $e) {
mysqli_rollback($this->link);
$this->disconnect();
return FALSE;
}
}