本文整理汇总了PHP中Movie::setRating方法的典型用法代码示例。如果您正苦于以下问题:PHP Movie::setRating方法的具体用法?PHP Movie::setRating怎么用?PHP Movie::setRating使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Movie
的用法示例。
在下文中一共展示了Movie::setRating方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMoviesFromDb
public function getMoviesFromDb($columnsNames = ["id", "name", "description", "rating"])
{
if (is_array($columnsNames) && !empty($columnsNames)) {
$columns = implode(",", $columnsNames);
$sqlQuery = "SELECT " . $columns . " FROM movies";
$conn = parent::getConnection();
$result = $conn->query($sqlQuery);
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
$movie = new Movie(parent::getConnection());
if (array_key_exists("id", $row)) {
$movie->setId($row["id"]);
}
if (array_key_exists("name", $row)) {
$movie->setName($row["name"]);
}
if (array_key_exists("description", $row)) {
$movie->setDescription($row["description"]);
}
if (array_key_exists("rating", $row)) {
$movie->setRating($row["rating"]);
}
$this->setArrayWithMovies($movie);
}
}
}
}
示例2: Game
include 'database_connection.php';
include 'classes/MediaItem.php';
include 'classes/Game.php';
include 'classes/Book.php';
include 'classes/Music.php';
include 'classes/Movie.php';
$game = new Game();
$game->setTitle('Watch Dogs');
$game->setDesc('Crappy shit wannabe hacker game');
$game->setRating(1);
$game->setTags(['dnt']);
print '<p>' . ($game->save() ? "Saving successful" : "Saving unsuccessful") . '</p>';
$book = new Book();
$book->setTitle('Momo');
$book->setDesc('Dreamy and so on');
$book->setRating(4);
$book->setTags(['tc']);
print '<p>' . ($book->save() ? "Saving successful" : "Saving unsuccessful") . '</p>';
$movie = new Movie();
$movie->setTitle('The big short');
$movie->setDesc('Capitalism');
$movie->setRating(3);
$movie->setTags(['tc', 'wtf']);
print '<p>' . ($movie->save() ? "Saving successful" : "Saving unsuccessful") . '</p>';
$music = new Music();
$music->setTitle('Bravo Hits 666');
$music->setDesc('Diabolic Bullshit');
$music->setRating(1);
$music->setTags(['dnt']);
print '<p>' . ($music->save() ? "Saving successful" : "Saving unsuccessful") . '</p>';
示例3: match
foreach (match_all('/<tr class="(even|odd)">(.*?)<\\/tr>/ms', $html, 2) as $m) {
$rank++;
$id = match('/<td class="titleColumn">.*?<a href="\\/title\\/(tt\\d+)\\/.*?"/msi', $m, 1);
$title = match('/<td class="titleColumn">.*?<a.*?>(.*?)<\\/a>/msi', $m, 1);
$year = match('/<td class="titleColumn">.*?<span.*?>\\((.*?)\\)<\\/span>/msi', $m, 1);
$rating = match('/<td class="ratingColumn">.*?<strong.*?>(.*?)<\\/strong>/msi', $m, 1);
$poster = match('/<td class="posterColumn">.*?<img src="(.*?)"/msi', $m, 1);
$votesURL = "http://www.imdb.com/title/" . $id . "/";
$votes = getvotes($votesURL);
// create each movie object and set the variables
$movie = new Movie();
$movie->setId($id);
$movie->setRank($rank);
$movie->setTitle($title);
$movie->setYear($year);
$movie->setRating($rating);
$movie->setVotes($votes);
// insert $movie objects into an array
array_push($top10Movies, $movie);
// stop at 10
if ($rank == 10) {
break;
}
}
$date = $db->select("movies", "date_added");
// insert into database using medoo if it does not exist
foreach ($top10Movies as $movie) {
// check database for matching date, if same day update, else insert
if (in_array($today, $date)) {
$db->update("movies", ["imdb_id" => $movie->getId(), "rank" => $movie->getRank(), "rating" => $movie->getRating(), "title" => $movie->getTitle(), "year" => $movie->getYear(), "number_of_votes" => $movie->getVotes(), "date_added" => $today], ["date_added" => $today, "rank" => $movie->getRank()]);
} else {