本文整理汇总了PHP中Movie::setDescription方法的典型用法代码示例。如果您正苦于以下问题:PHP Movie::setDescription方法的具体用法?PHP Movie::setDescription怎么用?PHP Movie::setDescription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Movie
的用法示例。
在下文中一共展示了Movie::setDescription方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: htmlentities
<?php
require_once "../classes/Database.php";
require_once "../classes/Movie.php";
if ($_SERVER["REQUEST_METHOD"] === "POST" && isset($_POST["movie_name"])) {
$name = htmlentities($_POST["movie_name"]);
$description = htmlentities($_POST["movie_description"]);
$rating = $_POST["movie_rating"];
$db = DATABASE::getInstance();
$mysqli = $db->getConnection();
$movie = new Movie($mysqli);
$movie->setName($name);
$movie->setDescription($description);
$movie->setRating($rating);
$movie->addToDatabase();
header("location: adminPanel.php");
} else {
header("location: adminPanel.php");
}