当前位置: 首页>>代码示例>>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;未经允许,请勿转载。