當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Author::getAll方法代碼示例

本文整理匯總了PHP中Author::getAll方法的典型用法代碼示例。如果您正苦於以下問題:PHP Author::getAll方法的具體用法?PHP Author::getAll怎麽用?PHP Author::getAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Author的用法示例。


在下文中一共展示了Author::getAll方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: find

 static function find($search_id)
 {
     $found_author = null;
     $authors = Author::getAll();
     foreach ($authors as $author) {
         if ($author->getId() == $search_id) {
             $found_author = $author;
         }
     }
     return $found_author;
 }
開發者ID:r-hills,項目名稱:library-1,代碼行數:11,代碼來源:Author.php

示例2: testDelete

 function testDelete()
 {
     $name = "Stephen King";
     $test_author = new Author($name);
     $test_author->save();
     $name2 = "Neal Stephenson";
     $test_author2 = new Author($name2);
     $test_author2->save();
     $test_author->delete();
     $this->assertEquals([$test_author2], Author::getAll());
 }
開發者ID:umamiMike,項目名稱:Library,代碼行數:11,代碼來源:AuthorTest.php

示例3: test_delete

 function test_delete()
 {
     $name = "Jerry Garcia";
     $test_author = new Author($name);
     $test_author->save();
     $name2 = "Frank Sinatra";
     $test_author2 = new Author($name2);
     $test_author2->save();
     $test_author->delete();
     $result = Author::getAll();
     $this->assertEquals([$test_author2], $result);
 }
開發者ID:nathanhwyoung,項目名稱:Library-2,代碼行數:12,代碼來源:AuthorTest.php

示例4: findByName

 static function findByName($search_name)
 {
     $found_author = null;
     $authors = Author::getAll();
     foreach ($authors as $author) {
         $author_name = $author->getAuthorName();
         if ($author_name == $search_name) {
             $found_author = $author;
         }
     }
     return $found_author;
 }
開發者ID:bdspen,項目名稱:library_day1,代碼行數:12,代碼來源:Author.php

示例5: find

 static function find($search_id)
 {
     $found = null;
     $authors = Author::getAll();
     foreach ($authors as $author) {
         $author_id = $author->getId();
         if ($author_id == $search_id) {
             $found = $author;
         }
     }
     //end foreach
     return $found;
 }
開發者ID:umamiMike,項目名稱:Library,代碼行數:13,代碼來源:Author.php

示例6: testDeleteAll

 function testDeleteAll()
 {
     //Arrange
     $name = "Name";
     $test_author = new Author($name);
     $test_author->save();
     $name2 = "New Name";
     $test_author2 = new Author($name2);
     $test_author2->save();
     //Act
     Author::deleteAll();
     $result = Author::getAll();
     //Assert
     $this->assertEquals([], $result);
 }
開發者ID:bencasalino,項目名稱:library,代碼行數:15,代碼來源:AuthorTest.php

示例7: testDeleteAll

 function testDeleteAll()
 {
     //Arrange
     $id = null;
     $name = "Lemony Snicket";
     $test_author = new Author($id, $name);
     $test_author->save();
     $name2 = "J.R.R. Tolkien";
     $test_author2 = new Author($id, $name2);
     $test_author2->save();
     //Act
     Author::deleteAll();
     //Assert
     $result = Author::getAll();
     $this->assertEquals([], $result);
 }
開發者ID:kellimargaret,項目名稱:2015.08.26.Library,代碼行數:16,代碼來源:AuthorTest.php

示例8: testDeleteAll

 function testDeleteAll()
 {
     //Arrange
     $name = "JK Rowling";
     $id = 1;
     $test_author = new Author($name, $id);
     $test_author->save();
     $name2 = "George RR Martin";
     $id2 = 2;
     $test_author2 = new Author($name, $id);
     $test_author2->save();
     //Act
     Author::deleteAll();
     $result = Author::getAll();
     //Assert
     $this->assertEquals([], $result);
 }
開發者ID:bborealis,項目名稱:library,代碼行數:17,代碼來源:AuthorTest.php

示例9: search

 static function search($search_name)
 {
     $found_authors = array();
     $authors = Author::getAll();
     foreach ($authors as $author) {
         $author_name = $author->getName();
         if ($author_name == $search_name) {
             array_push($found_authors, $author);
         }
     }
     $found_books = array();
     foreach ($found_authors as $author) {
         $books = $author->getBooks();
         array_push($found_books, $book);
     }
     return $found_books;
 }
開發者ID:bborealis,項目名稱:library-1,代碼行數:17,代碼來源:Author.php

示例10: findByAuthor

 static function findByAuthor($author_to_search)
 {
     $lower_search_author = strtolower($author_to_search);
     $found_books = [];
     $all_authors = Author::getAll();
     foreach ($all_authors as $author) {
         $author_name = strtolower($author->getName());
         // var_dump($author_name);
         // var_dump($lower_search_author);
         if ($author_name == $lower_search_author) {
             $books_by_author = $author->getBooks();
             var_dump($books_by_author);
             foreach ($books_by_author as $book) {
                 array_push($found_books, $book);
             }
         } else {
             return 0;
         }
     }
     return $found_books;
 }
開發者ID:kevintokheim,項目名稱:Liberry,代碼行數:21,代碼來源:Book.php

示例11: function

//Librarian Home
//Loads basic page
$app->get("/librarian_home", function () use($app) {
    return $app['twig']->render('librarian.html.twig', array('books' => Book::getAll()));
});
//allows user to post new books and view them on the same page
$app->post("/librarian_home", function () use($app) {
    $title = $_POST['title'];
    $author_first = $_POST['author_first_name'];
    $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'];
開發者ID:alexMcosta,項目名稱:library2,代碼行數:31,代碼來源:app.php

示例12: testDeleteOne

 function testDeleteOne()
 {
     //Arrange
     $author_name = "J.K. Rowling";
     $id = 1;
     $test_author = new Author($author_name, $id);
     $test_author->save();
     $author_name2 = "John Steinbeck";
     $id2 = 2;
     $test_author2 = new Author($author_name2, $id2);
     $test_author2->save();
     //Act
     $test_author->deleteOne();
     //Assert
     $this->assertEquals([$test_author2], Author::getAll());
 }
開發者ID:jtorrespdx,項目名稱:library_catalog,代碼行數:16,代碼來源:AuthorTest.php

示例13: testDeleteAuthor

 function testDeleteAuthor()
 {
     $name = "Hogan";
     $id = 1;
     $test_author = new Author($name, $id);
     $test_author->save();
     $name2 = "Koolaid Man";
     $id2 = 2;
     $test_author2 = new Author($name2, $id2);
     $test_author2->save();
     $test_author->deleteAuthor();
     $this->assertEquals([$test_author2], Author::getAll());
 }
開發者ID:bencasalino,項目名稱:library_day1,代碼行數:13,代碼來源:AuthorTest.php

示例14: array

    return $app['twig']->render('post_new.html.twig', array('authors' => $authorsToDisplay));
})->bind('post_new');
$app->post('/post/add', function (Request $request) use($app) {
    $postModel = new Post($app['db']);
    $authorId = $request->request->get('author_id');
    if (!isset($authorId)) {
        $app->abort(404, 'Author has to be selected. Go back and select author');
    }
    $title = $request->request->get('title');
    $message = $request->request->get('message');
    $postModel->set($title, $message, $authorId);
    return $app->redirect($app["url_generator"]->generate("post_index"));
})->bind('post_add');
$app->get('/authors', function () use($app) {
    $authorModel = new Author($app['db']);
    $authorsToDisplay = $authorModel->getAll();
    return $app['twig']->render('author_index.html.twig', array('authors' => $authorsToDisplay));
})->bind('author_index');
$app->get('/author/{author_id}', function ($author_id) use($app) {
    $authorModel = new Author($app['db']);
    $authorToDisplay = $authorModel->get($author_id);
    if (!$authorToDisplay) {
        $app->abort(404, 'The article could not be found');
    }
    return $app['twig']->render('author_single.html.twig', array('author' => $authorToDisplay));
})->assert('author_id', '\\d+')->bind('author_single');
$app->get('/author/new', function () use($app) {
    return $app['twig']->render('author_new.html.twig');
})->bind('author_new');
$app->post('/author/add', function (Request $request) use($app) {
    $authorModel = new Author($app['db']);
開發者ID:marchage,項目名稱:phpsilexblog,代碼行數:31,代碼來源:index.php

示例15: testDeleteOne

 function testDeleteOne()
 {
     //Arrange
     $first_name = "J.K.";
     $last_name = "Rowling";
     $test_author = new Author($first_name, $last_name);
     $test_author->save();
     $first_name2 = "John";
     $last_name2 = "Steinbeck";
     $test_author2 = new Author($first_name2, $last_name2);
     $test_author2->save();
     //Act
     $test_author->deleteOne();
     //Assert
     $this->assertEquals([$test_author2], Author::getAll());
 }
開發者ID:jtorrespdx,項目名稱:library,代碼行數:16,代碼來源:AuthorTest.php


注:本文中的Author::getAll方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。