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


PHP Book::search方法代码示例

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


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

示例1: getIndex

 public function getIndex()
 {
     # Format and Query are passed as Query Strings
     $format = Input::get('format', 'html');
     $query = Input::get('query');
     $books = Book::search($query);
     # Decide on output method...
     # Default - HTML
     if ($format == 'html') {
         return View::make('book_index')->with('books', $books)->with('query', $query);
     } elseif ($format == 'json') {
         return Response::json($books);
     } elseif ($format == 'pdf') {
         return "This is the pdf (Coming soon).";
     }
 }
开发者ID:rebekahheacock,项目名称:dwa15-archive,代码行数:16,代码来源:BookController.php

示例2: Course

foreach ($courses as $c) {
    echo $c->getDescription() . "\n";
}
$c = new Course();
$c->setId(1);
$c->load();
echo $c->getDescription() . "\n";
$students = $c->getStudents();
foreach ($students as $s) {
    echo $s->getName() . "\n";
}
//SEARCH
$p = new Person();
$p->setName('Mat');
$search = $p->search();
$search->orderBy('name');
$list = $search->execute();
foreach ($list as $p) {
    echo $p->getName() . "\n";
}
//Recursive Search
$c = new City();
$c->setName('San');
$p = new Person();
$p->setCity($c);
$b = new Book();
$b->setAuthor($p);
$list = $b->search()->execute();
foreach ($list as $b) {
    echo $b->getTitle() . "\n";
}
开发者ID:mateusfornari,项目名称:hypersistence-alpha,代码行数:31,代码来源:index.php

示例3: array

    $title = $_POST['title'];
    $book->update($title);
    $authors = $book->getAuthors();
    $copies = Copy::findCopies($id);
    return $app['twig']->render('book.html.twig', array('book' => $book, 'authors' => $authors, 'all_authors' => Author::getAll(), 'copies' => $copies));
});
$app->post("/add_authors", function () use($app) {
    $book = Book::find($_POST['book_id']);
    $author = Author::find($_POST['author_id']);
    $book->addAuthor($author);
    $copies = Copy::findCopies($_POST['book_id']);
    return $app['twig']->render('book.html.twig', array('book' => $book, 'authors' => $book->getAuthors(), 'all_authors' => Author::getAll(), 'copies' => $copies));
});
//book search result page
$app->get("/search_books", function () use($app) {
    $search = Book::search($_GET['search']);
    return $app['twig']->render('search_books.html.twig', array('search' => $search, 'search_book' => $_GET['search']));
});
//author search result page
$app->get("/search_authors", function () use($app) {
    $search = Author::search($_GET['search']);
    return $app['twig']->render('search_authors.html.twig', array('search' => $search, 'search_author' => $_GET['search']));
});
//authors
$app->get("/authors", function () use($app) {
    return $app['twig']->render('authors.html.twig', array('authors' => Author::getAll()));
});
$app->get("/author/{id}", function ($id) use($app) {
    $author = Author::find($id);
    $book = $author->getAuthors();
    return $app['twig']->render('author.html.twig', array('book' => $book, 'author' => $author));
开发者ID:bborealis,项目名称:library,代码行数:31,代码来源:app.php

示例4: postSearch

 /**
  * Process a book search
  * Called w/ Ajax
  */
 public function postSearch()
 {
     if (Request::ajax()) {
         $query = Input::get('query');
         # We're demoing two possible return formats: JSON or HTML
         $format = Input::get('format');
         # Do the actual query
         $books = Book::search($query);
         # If the request is for JSON, just send the books back as JSON
         if ($format == 'json') {
             return Response::json($books);
         } elseif ($format == 'html') {
             $results = '';
             foreach ($books as $book) {
                 # Created a "stub" of a view called book_search_result.php; all it is is a stub of code to display a book
                 # For each book, we'll add a new stub to the results
                 $results .= View::make('book_search_result')->with('book', $book)->render();
             }
             # Return the HTML/View to JavaScript...
             return $results;
         }
     }
 }
开发者ID:rebekahheacock,项目名称:dwa15-archive,代码行数:27,代码来源:BookController.php


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