本文整理汇总了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).";
}
}
示例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";
}
示例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));
示例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;
}
}
}