当前位置: 首页>>代码示例>>PHP>>正文


PHP Book::searchByTitle方法代码示例

本文整理汇总了PHP中Book::searchByTitle方法的典型用法代码示例。如果您正苦于以下问题:PHP Book::searchByTitle方法的具体用法?PHP Book::searchByTitle怎么用?PHP Book::searchByTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Book的用法示例。


在下文中一共展示了Book::searchByTitle方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testSearchByTitle

 function testSearchByTitle()
 {
     //Arrange
     $title = "The Cat in the Hat";
     $test_book = new Book($title);
     $test_book->save();
     $title2 = "Misery";
     $test_book2 = new Book($title2);
     $test_book2->save();
     $title3 = "Cat on a Hot Tin Roof";
     $test_book3 = new Book($title3);
     $test_book3->save();
     $search_string = "Cat";
     //Act
     $result = Book::searchByTitle($search_string);
     //Assert
     $this->assertEquals([$test_book, $test_book3], $result);
 }
开发者ID:jtorrespdx,项目名称:library,代码行数:18,代码来源:BookTest.php

示例2: Book

    $author_last = $_POST['author_last_name'];
    $book = new Book($title);
    $book->save();
    $author = new Author($author_first, $author_last);
    $author->save();
    $author->addBook($book);
    return $app['twig']->render('librarian.html.twig', array('books' => Book::getAll(), 'authors' => Author::getAll()));
});
//Book page
$app->get("/books/{id}", function ($id) use($app) {
    $book = Book::find($id);
    $author = $book->getAuthor();
    return $app['twig']->render('book.html.twig', array('book' => $book, 'author' => $author));
});
//Search for title or author
$app->post("/search/title", function () use($app) {
    $title = $_POST['search_title'];
    $books = Book::searchByTitle($title);
    return $app['twig']->render('search_results.html.twig', array('books' => $books));
});
$app->post("/search/author", function () use($app) {
    $author = $_POST['search_author'];
    $books = Author::searchByAuthorLast($author);
    return $app['twig']->render('search_results.html.twig', array('books' => $books));
});
//allows user to delete all books
$app->post("/clear_library", function () use($app) {
    Book::deleteAll();
    return $app['twig']->render('librarian.html.twig', array('books' => Book::getAll()));
});
return $app;
开发者ID:alexMcosta,项目名称:library2,代码行数:31,代码来源:app.php

示例3: array

    $book->updateAuthorFirst($author_first);
    return $app['twig']->render('add_book.html.twig', array('books' => Book::getAll()));
});
$app->patch("/book/{id}/authorlast", function ($id) use($app) {
    $author_last = $_POST['author_last'];
    $book = Book::find($id);
    $book->updateAuthorLast($author_last);
    return $app['twig']->render('add_book.html.twig', array('books' => Book::getAll()));
});
$app->patch("/book/{id}/title", function ($id) use($app) {
    $title = $_POST['title'];
    $book = Book::find($id);
    $book->updateTitle($title);
    return $app['twig']->render('add_book.html.twig', array('books' => Book::getAll()));
});
$app->delete("/book/{id}", function ($id) use($app) {
    $book = Book::find($id);
    $book->deleteOne();
    return $app['twig']->render('add_book.html.twig', array('books' => Book::getAll()));
});
$app->post("/search/title", function () use($app) {
    $title = $_POST['search_title'];
    $matches = Book::searchByTitle($title);
    return $app['twig']->render('search_results.html.twig', array('matches' => $matches));
});
$app->post("/search/author", function () use($app) {
    $author = $_POST['search_author'];
    $matches = Book::searchByAuthorLast($author);
    return $app['twig']->render('search_results.html.twig', array('matches' => $matches));
});
return $app;
开发者ID:alexMcosta,项目名称:library,代码行数:31,代码来源:app.php

示例4: testSearchByTitle

 function testSearchByTitle()
 {
     //Arrange
     $author_first = "Dr.";
     $author_last = "Seuss";
     $title = "The Cat in the Hat";
     $test_book = new Book($author_first, $author_last, $title);
     $test_book->save();
     $author_first2 = "Stephen";
     $author_last2 = "King";
     $title2 = "Misery";
     $test_book2 = new Book($author_first2, $author_last2, $title2);
     $test_book2->save();
     $author_first3 = "Tennessee";
     $author_last3 = "Williams";
     $title3 = "Cat on a Hot Tin Roof";
     $test_book3 = new Book($author_first3, $author_last3, $title3);
     $test_book3->save();
     $search_string = "Cat";
     //Act
     $result = Book::searchByTitle($search_string);
     //Assert
     $this->assertEquals([$test_book, $test_book3], $result);
 }
开发者ID:alexMcosta,项目名称:library,代码行数:24,代码来源:BookTest.php

示例5: testSearchByTitle

 function testSearchByTitle()
 {
     //Arrange
     $author_first = "J.K.";
     $author_last = "Rowling";
     $test_author = new Author($author_first, $author_last);
     $test_author->save();
     $author_first2 = "Stephen";
     $author_last2 = "King";
     $test_author2 = new Author($author_first2, $author_last2);
     $test_author2->save();
     $author_first3 = "John";
     $author_last3 = "Steinbeck";
     $test_author3 = new Author($author_first2, $author_last2);
     $test_author3->save();
     $title = "Grapes of Wrath";
     $test_book = new Book($title);
     $test_book->save();
     $test_book->addAuthor($test_author3);
     $title2 = "Harry Potter";
     $test_book2 = new Book($title2);
     $test_book2->save();
     $test_book2->addAuthor($test_author);
     $title3 = "Evil Wrath";
     $test_book3 = new Book($title3);
     $test_book3->save();
     $test_book3->addAuthor($test_author2);
     $search_string = "Wrath";
     //Act
     $result = Book::searchByTitle($search_string);
     //Assert
     $this->assertEquals([$test_book, $test_book3], $result);
 }
开发者ID:alexMcosta,项目名称:library2,代码行数:33,代码来源:BookTest.php


注:本文中的Book::searchByTitle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。