本文整理匯總了PHP中Book::setName方法的典型用法代碼示例。如果您正苦於以下問題:PHP Book::setName方法的具體用法?PHP Book::setName怎麽用?PHP Book::setName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Book
的用法示例。
在下文中一共展示了Book::setName方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: findOne
/**
* fake for test
*/
public function findOne($con = null)
{
if (true === $this->bySlug) {
$book = new Book();
$book->setId(1);
$book->setName('My Book');
$book->setSlug('my-book');
return $book;
}
return null;
}
示例2: handlePUT
function handlePUT()
{
$conn = Connection::startConnection();
parse_str(file_get_contents("php://input"), $data);
header('Content-type: application/json');
$book = new Book();
$book->setName($data['name']);
$book->setAuthor($data['author']);
$book->setDesc($data['opis']);
$book->updateBook($conn, $data['id']);
Connection::stopConnecion($conn);
}
示例3: findOrCreateOne
public function findOrCreateOne($book_name)
{
# Attempt to find book
$book = BookQuery::create()->filterByName($book_name)->findOne();
# Return or create book
if ($book) {
return $book;
} else {
$book = new Book();
$book->setName($book_name)->save();
return $book;
}
}
示例4: setName
public function setName($newName)
{
parent::setName($newName . " - wersja cyfrowa");
}
示例5: getName
<?php
trait NameTrait
{
private $name;
public function getName()
{
return $this->name;
}
public function setName($name)
{
return $this->name = $name;
}
}
class Book
{
use NameTrait;
}
$book = new Book();
$book->setName('PHP Cookbook');
print $book->getName();