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


PHP Book::getAll方法代码示例

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


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

示例1: find

 static function find($searchId)
 {
     $books = Book::getAll();
     foreach ($books as $book) {
         if ($searchId = $book->getId()) {
             return $book;
         }
     }
 }
开发者ID:jschold,项目名称:Library,代码行数:9,代码来源:Book.php

示例2: testUpdate

 function testUpdate()
 {
     $book_name = "Siddhartha";
     $test_book = new Book($book_name);
     $test_book->save();
     $test_book->setTitle("Peace Train");
     $test_book->update();
     $result = Book::getAll();
     $this->assertEquals($test_book, $result[0]);
 }
开发者ID:JordanNavratil,项目名称:Library,代码行数:10,代码来源:BookTest.php

示例3: testDelete

 function testDelete()
 {
     $title = "Anathem";
     $test_book = new Book($title);
     $test_book->save();
     $title2 = "Snow Crash";
     $test_book2 = new Book($title2);
     $test_book2->save();
     $test_book->delete();
     $this->assertEquals([$test_book2], Book::getAll());
 }
开发者ID:umamiMike,项目名称:library-1,代码行数:11,代码来源:BookTest.php

示例4: test_delete

 function test_delete()
 {
     $title = "Three Blind Mice";
     $test_book = new Book($title);
     $test_book->save();
     $title2 = "Chicken Dog";
     $test_book2 = new Book($title2);
     $test_book2->save();
     $test_book->delete();
     $result = Book::getAll();
     $this->assertEquals([$test_book2], $result);
 }
开发者ID:juliocesardiaz,项目名称:Library,代码行数:12,代码来源:BookTest.php

示例5: search

 static function search($search_title)
 {
     $found_books = array();
     $books = Book::getAll();
     foreach ($books as $book) {
         $book_title = $book->getTitle();
         if ($book_title == $search_title) {
             array_push($found_books, $book);
         }
     }
     return $found_books;
 }
开发者ID:bborealis,项目名称:library-1,代码行数:12,代码来源:Book.php

示例6: testDeleteOne

 function testDeleteOne()
 {
     $book_name = "Rum diaries";
     $test_book = new Book($book_name);
     $test_book->save();
     $book_name = "Yer not a wizard harry";
     $test_book2 = new Book($book_name);
     $test_book2->save();
     $test_book->deleteOne();
     $result = Book::getAll();
     $this->assertEquals([$test_book2], $result);
 }
开发者ID:jschold,项目名称:Library,代码行数:12,代码来源:BookTest.php

示例7: find

 static function find($search_id)
 {
     $found_book = null;
     $books = Book::getAll();
     foreach ($books as $book) {
         $book_id = $book->getId();
         if ($book_id == $search_id) {
             $found_book = $book;
         }
     }
     return $found_book;
 }
开发者ID:bdspen,项目名称:library_day1,代码行数:12,代码来源:Book.php

示例8: testDeleteAll

 function testDeleteAll()
 {
     //Arrange
     $title = "Title";
     $test_book = new Book($title);
     $test_book->save();
     $title2 = "New Title";
     $test_book2 = new Book($title2);
     $test_book2->save();
     //Act
     Book::deleteAll();
     $result = Book::getAll();
     //Assert
     $this->assertEquals([], $result);
 }
开发者ID:bdspen,项目名称:library,代码行数:15,代码来源:BookTest.php

示例9: testDeleteAll

 function testDeleteAll()
 {
     //Arrange
     $book_name = "Intro to Art";
     $test_book = new Book($book_name);
     $test_book->save();
     $book_name2 = "Intro to Spanish";
     $book_author2 = "SPN101";
     $test_book2 = new Book($book_name2);
     $test_book2->save();
     //Act
     Book::deleteAll();
     $result = Book::getAll();
     //Assert
     $this->assertEquals([], $result);
 }
开发者ID:kevintokheim,项目名称:Library,代码行数:16,代码来源:BookTest.php

示例10: testDeleteAll

 function testDeleteAll()
 {
     //Arrange
     $title = "Harry Potter";
     $id = 1;
     $test_book = new Book($title, $id);
     $test_book->save();
     $title2 = "Moby Dick";
     $id2 = 2;
     $test_book2 = new Book($title, $id);
     $test_book2->save();
     //Act
     Book::deleteAll();
     $result = Book::getAll();
     //Assert
     $this->assertEquals([], $result);
 }
开发者ID:bborealis,项目名称:library,代码行数:17,代码来源:BookTest.php

示例11: testDeleteAll

 function testDeleteAll()
 {
     //Arrange
     $title = "Speaker for the Dead";
     $date = "1987";
     $id = null;
     $test_book = new Book($title, $date, $id);
     $test_book->save();
     $title2 = "Frankenstein";
     $date2 = "1750";
     $id2 = null;
     $test_book2 = new Book($title2, $date2, $id2);
     $test_book2->save();
     //Act
     Book::deleteAll();
     //Assert
     $result = Book::getAll();
     $this->assertEquals([], $result);
 }
开发者ID:Camolot,项目名称:library,代码行数:19,代码来源:BooksTest.php

示例12: searchByTitle

 static function searchByTitle($search_string)
 {
     $clean_search_string = preg_replace('/[^A-Za-z0-9\\s]/', '', $search_string);
     $lower_clean_search_string = strtolower($clean_search_string);
     $exploded_lower_clean_search_string = explode(' ', $lower_clean_search_string);
     $books = Book::getAll();
     $matches = array();
     foreach ($exploded_lower_clean_search_string as $word) {
         foreach ($books as $book) {
             $title = $book->getTitle();
             $clean_title = preg_replace('/[^A-Za-z0-9\\s]/', '', $title);
             $lower_clean_title = strtolower($clean_title);
             $explode_lower_clean_title = explode(' ', $lower_clean_title);
             foreach ($explode_lower_clean_title as $title_pieces) {
                 if ($title_pieces == $word) {
                     array_push($matches, $book);
                 }
             }
         }
     }
     return $matches;
 }
开发者ID:jtorrespdx,项目名称:library,代码行数:22,代码来源:Book.php

示例13: function

});
$app->patch("/book/{id}", function ($id) use($app) {
    $book = Book::find($id);
    if (!empty($_POST['title'])) {
        $new_title = $_POST['title'];
        $book->updateTitle($new_title);
    }
    if (!empty($_POST['author'])) {
        $author_name = $_POST['author'];
        $book->updateAuthor($book->checkAuthor($author_name));
    }
    if (!empty($_POST['add_author'])) {
        $author_name = $_POST['add_author'];
        $book->addAuthor($book->checkAuthor($author_name));
    }
    if (!empty($_POST['add_copies'])) {
        $add_copies = $_POST['add_copies'];
        $book->updateCopies($add_copies);
    }
    return $app['twig']->render('librarian.html.twig', array('books' => Book::getAll(), 'authors' => Author::getAll()));
});
$app->post("/delete_all_books", function () use($app) {
    Book::deleteAll();
    return $app['twig']->render('librarian.html.twig', array('books' => Book::getAll(), 'authors' => Author::getAll()));
});
$app->delete("/book/{id}/delete_author", function ($id) use($app) {
    $book = Book::find($id);
    $book->deleteAuthor($_POST['author_id']);
    return $app['twig']->render('librarian.html.twig', array('books' => Book::getAll(), 'authors' => Author::getAll()));
});
return $app;
开发者ID:bdspen,项目名称:library_day1,代码行数:31,代码来源:app.php

示例14: testDeleteOne

 function testDeleteOne()
 {
     //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();
     //Act
     $test_book->deleteOne();
     $result = Book::getAll();
     //Assert
     $this->assertEquals($test_book2, $result[0]);
 }
开发者ID:jtorrespdx,项目名称:library,代码行数:15,代码来源:BookTest.php

示例15: PDO

require_once __DIR__ . "/../src/Author.php";
require_once __DIR__ . "/../src/Book.php";
$app = new Silex\Application();
$app['debug'] = true;
$server = 'mysql:host=localhost;dbname=library';
$username = 'root';
$password = 'root';
$DB = new PDO($server, $username, $password);
use Symfony\Component\HttpFoundation\Request;
Request::enableHttpMethodParameterOverride();
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
$app->get("/", function () use($app) {
    return $app['twig']->render('index.html.twig', array('authors' => Author::getAll(), 'books' => Book::getAll()));
});
$app->post("/author_book", function () use($app) {
    $title = $_POST['title'];
    $book = new Book($title, $id = null);
    $book->save();
    $name = $_POST['name'];
    $author = new Author($name, $id = null);
    $author->save();
    $result = $author->addBook($book);
    return $app['twig']->render('index.html.twig', array('books' => Book::getAll(), 'authors' => Author::getAll()));
});
$app->post("/delete_all", function () use($app) {
    $GLOBALS['DB']->exec("DELETE FROM authors_books_t;");
    Author::deleteAll();
    Book::deleteAll();
    return $app['twig']->render('index.html.twig', array('authors' => Author::getAll(), 'books' => Book::getAll()));
});
return $app;
开发者ID:CaseyH33,项目名称:Library,代码行数:31,代码来源:app.php


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