本文整理汇总了PHP中Book类的典型用法代码示例。如果您正苦于以下问题:PHP Book类的具体用法?PHP Book怎么用?PHP Book使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Book类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: procGetIDNum
private function procGetIDNum($session)
{
$queryType = @$_GET['type'];
shell_exec("java PHPHandler requestRFIDTagId");
$idNum = (string) shell_exec("java PHPHandler downloadRFID");
if ($queryType == "add") {
$session->form->setValue("rfid", $idNum);
$_SESSION['value_array'] = $session->form->getValueArray();
session_write_close();
header("Location: bookProcess.php?submitBookChanges&type=" . $queryType);
} else {
if ($queryType == "change" || $queryType == "remove") {
$book = new Book();
$result = $book->getBookCallNo($idNum);
$callNo = $result['CallNo'];
header("Location: bookProcess.php?setupChangeList&type=" . $queryType . "&callNo=" . $callNo . "");
} else {
if ($queryType == "checkinout") {
$book = new Book();
$result = $book->getBookCallNo($idNum);
$callNo = $result['CallNo'];
header("Location: librarianProcess.php?checkinout&s=1&callNo=" . $callNo . "");
}
}
}
}
示例2: books
function books()
{
$objs = new Book();
$objs->get();
$data = array('books' => $objs);
$this->load->view('backend/books', $data);
}
示例3: testFormatALotOfResults
public function testFormatALotOfResults()
{
$nbBooks = 50;
$con = Propel::getConnection(BookPeer::DATABASE_NAME);
Propel::disableInstancePooling();
$book = new Book();
for ($i = 0; $i < $nbBooks; $i++) {
$book->clear();
$book->setTitle('BookTest' . $i);
$book->save($con);
}
$stmt = $con->query('SELECT * FROM book');
$formatter = new PropelOnDemandFormatter();
$formatter->init(new ModelCriteria('bookstore', 'Book'));
$books = $formatter->format($stmt);
$this->assertTrue($books instanceof PropelOnDemandCollection, 'PropelOnDemandFormatter::format() returns a PropelOnDemandCollection');
$this->assertEquals($nbBooks, count($books), 'PropelOnDemandFormatter::format() returns a collection that counts as many rows as the results in the query');
$i = 0;
foreach ($books as $book) {
$this->assertTrue($book instanceof Book, 'PropelOnDemandFormatter::format() returns a collection of Model objects');
$this->assertEquals('BookTest' . $i, $book->getTitle(), 'PropelOnDemandFormatter::format() returns the model objects matching the query');
$i++;
}
Propel::enableInstancePooling();
}
示例4: testGetId
function testGetId()
{
$name = "Randy Mclure";
$test_patron = new Book($name);
$result = $test_patron->getId();
$this->assertEquals(null, $result);
}
示例5: update
function update()
{
$params = $this->input->post();
$obj = new Book();
$obj->where('id', $params['id'])->update($params);
echo $obj->check_last_query();
}
示例6: bookInsertion
function bookInsertion($title, $ISBN, $author)
{
$book = new \Book(['title' => $title, 'isbn' => $ISBN]);
$book->link('author', $author);
$book->save();
return $book;
}
示例7: __construct
/**
* __construct method
*/
public function __construct(View $view, $settings = array())
{
parent::__construct($view, $settings);
App::import("Model", 'Book');
$Book = new Book();
$this->calibrePath = $Book->getCalibrePath();
}
示例8: hallAction
public function hallAction()
{
$this->view->loginuser = $_SESSION['loginuser'];
$book = new Book();
$res = $book->fetchAll()->toArray();
$this->view->res = $res;
}
示例9: test_create_from_array
public function test_create_from_array()
{
$data = array('title' => 'New Book', 'author_id' => '1', 'quantity' => '500', 'price' => '7.77');
// 'New Book' doesn't exist
// i.e. test may be invalid
$book = new Book();
$book = $book->find_by_title('New Book');
if (count($book) != 0) {
$this->errors['create_from_array'][] = 'pre-exists';
}
$new_book = new Book();
$new_book->create($data);
// 'New Book' was created
// e.g. create() isn't working
if (is_null($new_book->id)) {
$this->errors['create_from_array'][] = 'new_book_id';
}
// 'New Book' can be fetched
// e.g. update() isn't working
$fetch_book = new Book();
$fetch_book = $fetch_book->find_by_title('New Book');
if (count($fetch_book) != 1) {
$this->errors['create_from_array'][] = 'fetch_count';
}
if ($fetch_book[0]->id != $new_book->id) {
$this->errors['create_from_array'][] = 'fetch_id_match';
}
}
示例10: test_update_from_array
public function test_update_from_array()
{
$data = array('title' => 'New Book', 'author_id' => '1', 'quantity' => '500', 'price' => '7.77');
// Create Book to test
$new_book = new Book();
$new_book->create($data);
// 'New Book' exists
// i.e. test may be invalid
$book = new Book();
$book = $book->find_by_title('New Book');
if (count($book) == 0) {
$this->errors['update_from_array'][] = 'non-existent';
}
if (count($book) > 1) {
$this->errors['update_from_array'][] = 'too_many';
}
$new_data = array('author_id' => '2', 'quantity' => '600', 'price' => '8.88');
$update_book = new Book();
$update_book = $update_book->first_by_title('New Book');
$update_book->update($new_data);
// Fetch book
// e.g. update() isn't working
$fetch_book = new Book();
$fetch_book = $fetch_book->first_by_title('New Book');
if ($fetch_book->author_id != 2) {
$this->errors['update_from_array'][] = 'author_id';
}
if ($fetch_book->quantity != 600) {
$this->errors['update_from_array'][] = 'quantity';
}
if ($fetch_book->price != '8.88') {
$this->errors['update_from_array'][] = 'price';
}
}
示例11: testTicket2
public function testTicket2()
{
$obj = new Book();
$obj->set('name', 'yes2');
$obj->save();
$this->assertEqual($obj->get('name'), 'yes2');
$obj->save();
}
示例12: process
/**
* @return bool
* @throws Exception
*/
public function process()
{
$bookModel = new Book();
if (!$bookModel->load($this->data) || !$bookModel->validate()) {
throw new Exception('Invalid data!');
}
return $bookModel->delete();
}
示例13: testWeCanCreateABookWithInformation
public function testWeCanCreateABookWithInformation()
{
$title = 'New Title';
$author = "Author";
$book = new Book($title, $author);
$this->assertEquals($title, $book->getTitle());
$this->assertEquals($author, $book->getAuthor());
}
示例14: removeBook
public function removeBook(Book $bookToRemove)
{
foreach ($this->books as $key => $book) {
/** @var Book $book */
if ($book->getAuthorAndTitle() === $bookToRemove->getAuthorAndTitle()) {
unset($this->books[$key]);
}
}
}
示例15: bookInsertion
function bookInsertion($title, $ISBN, $author)
{
$book = new \Book();
$book->title = $title;
$book->isbn = $ISBN;
$book->author()->associate($author);
$book->save();
return $book;
}