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


PHP Author::find方法代码示例

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


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

示例1: postEdit

 public function postEdit($id)
 {
     if (!$this->checkRoute()) {
         return Redirect::route('index');
     }
     $title = 'Edit An Author - ' . $this->site_name;
     $author = Author::find($id);
     $input = Input::only('name', 'deck', 'website', 'donate_link', 'bio', 'slug');
     $messages = ['unique' => 'The author already exists in the database.', 'url' => 'The :attribute field is not a valid URL.'];
     $validator = Validator::make($input, ['name' => 'required|unique:authors,name,' . $author->id, 'website' => 'url', 'donate_link' => 'url'], $messages);
     if ($validator->fails()) {
         return Redirect::action('AuthorController@getEdit', [$id])->withErrors($validator)->withInput();
     }
     $author->name = $input['name'];
     $author->deck = $input['deck'];
     $author->website = $input['website'];
     $author->donate_link = $input['donate_link'];
     $author->bio = $input['bio'];
     if ($input['slug'] == '' || $input['slug'] == $author->slug) {
         $slug = Str::slug($input['name']);
     } else {
         $slug = $input['slug'];
     }
     $author->slug = $slug;
     $author->last_ip = Request::getClientIp();
     $success = $author->save();
     if ($success) {
         return View::make('authors.edit', ['title' => $title, 'success' => true, 'author' => $author]);
     }
     return Redirect::action('AuthorController@getEdit', [$id])->withErrors(['message' => 'Unable to add author.'])->withInput();
 }
开发者ID:helkarakse,项目名称:modpackindex,代码行数:31,代码来源:AuthorController.php

示例2: get

 /**
  * Get one Author
  *
  * return array {@type Author}
  *
  * @view authorDetailView
  *
  */
 public function get($id)
 {
     if (!($feedback = Author::find($id))) {
         throw new RestException(404, 'feedback not found');
     }
     return $feedback;
 }
开发者ID:Alim-ifresco,项目名称:project1.dev4.why.sr,代码行数:15,代码来源:Authors.php

示例3: author

 public function author($id)
 {
     $author = Author::find($id);
     $books = DB::table('katalog')->join('author_katalog', 'katalog.id', '=', 'author_katalog.idkatalog')->where('author_katalog.author', '=', $id)->get(array('katalog.title', 'katalog.release', 'katalog.id', 'katalog.category'));
     $comment = Comment::where('id_obj', '=', $author->id)->where('cat_comment', '=', 2)->get();
     $act = 'person';
     return View::make('front.author', compact('author', 'books', 'comment', 'act'));
 }
开发者ID:beruxganteng,项目名称:repository-djpbn,代码行数:8,代码来源:ListController.php

示例4: test_find

 function test_find()
 {
     $name = "Jerry Garcia";
     $test_author = new Author($name);
     $test_author->save();
     $name2 = "Frank Sinatra";
     $test_author2 = new Author($name2);
     $test_author2->save();
     $result = Author::find($test_author->getId());
     $this->assertEquals($test_author, $result);
 }
开发者ID:nathanhwyoung,项目名称:Library-2,代码行数:11,代码来源:AuthorTest.php

示例5: testFind

 function testFind()
 {
     $name = "Stephen King";
     $test_author = new Author($name);
     $test_author->save();
     $name2 = "Neal Stephenson";
     $test_author2 = new Author($name2);
     $test_author2->save();
     $result = Author::find($test_author->getId());
     $this->assertEquals($result, $test_author);
 }
开发者ID:umamiMike,项目名称:Library,代码行数:11,代码来源:AuthorTest.php

示例6: testSaveSelect

 /** <tt>find a unexistent record</tt> */
 public function testSaveSelect()
 {
     $item = new Author();
     $item->name = 'Mihai Eminescu';
     $item->save();
     try {
         $items = Author::find(100);
         $this->fail('Should throw an exception!');
     } catch (Exception $ex) {
         $this->assertIsA($ex, 'RecordNotFoundException');
     }
     $item->delete();
 }
开发者ID:BackupTheBerlios,项目名称:medick-svn,代码行数:14,代码来源:DBOperationsTest.php

示例7: testFind

 function testFind()
 {
     //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
     $result = Author::find($test_author->getId());
     //Assert
     $this->assertEquals($test_author, $result);
 }
开发者ID:kellimargaret,项目名称:2015.08.26.Library,代码行数:15,代码来源:AuthorTest.php

示例8: testFind

 function testFind()
 {
     //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
     $result = Author::find($test_author2->getId());
     //Assert
     $this->assertEquals($test_author2, $result);
 }
开发者ID:bborealis,项目名称:library,代码行数:16,代码来源:AuthorTest.php

示例9: test_find_by_datetime

 public function test_find_by_datetime()
 {
     $now = new DateTime();
     $arnow = new ActiveRecord\DateTime();
     $arnow->setTimestamp($now->getTimestamp());
     Author::find(1)->update_attribute('created_at', $now);
     $this->assert_not_null(Author::find_by_created_at($now));
     $this->assert_not_null(Author::find_by_created_at($arnow));
 }
开发者ID:J1Duran,项目名称:ph-web,代码行数:9,代码来源:ActiveRecordFindTest.php

示例10: testFind

 function testFind()
 {
     //Arrange
     $author_name = "Frank Herbert";
     $id = null;
     $test_author = new Author($author_name, $id);
     $test_author->save();
     $author_name2 = "Neal Stephenson";
     $id2 = null;
     $test_author2 = new Author($author_name2, $id2);
     $test_author2->save();
     //Act
     $result = Author::find($test_author->getId());
     //Assert
     $this->assertEquals($test_author, $result);
 }
开发者ID:juliocesardiaz,项目名称:library-1,代码行数:16,代码来源:AuthorTest.php

示例11: array

    $new_book->save();
    return $app['twig']->render('books.html.twig', array('books' => Book::getAll()));
});
$app->post("/authors", function () use($app) {
    $new_author = new Author($_POST['name']);
    $new_author->save();
    return $app['twig']->render('authors.html.twig', array('authors' => Author::getAll()));
});
$app->post("/patrons", function () use($app) {
    $new_patron = new Patron($_POST['name']);
    $new_patron->save();
    return $app['twig']->render('patrons.html.twig', array('patrons' => Patron::getAll()));
});
$app->post("/add_author", function () use($app) {
    $book = Book::find($_POST['book_id']);
    $author = Author::find($_POST['author_id']);
    $book->addAuthor($author);
    return $app['twig']->render('book.html.twig', array('copies' => $book->getCopies(), 'book' => $book, 'authors' => $book->getAuthors(), 'all_authors' => Author::getAll()));
});
$app->post("/add_book", function () use($app) {
    $book = Book::find($_POST['book_id']);
    $author = Author::find($_POST['author_id']);
    $author->addBook($book);
    return $app['twig']->render('author.html.twig', array('author' => $author, 'books' => $author->getBooks(), 'all_books' => Book::getAll()));
});
$app->post("/add_copy", function () use($app) {
    $book = Book::find($_POST['book_id']);
    $book->addCopy();
    return $app['twig']->render('book.html.twig', array('copies' => $book->getCopies(), 'book' => $book, 'authors' => $book->getAuthors(), 'all_authors' => Author::getAll()));
});
return $app;
开发者ID:jlbethel,项目名称:Library,代码行数:31,代码来源:app.php

示例12: testCreationOfEmptyRecord

 /**
  * testCreationOfEmptyRecord method
  *
  * @return void
  */
 public function testCreationOfEmptyRecord()
 {
     $this->loadFixtures('Author');
     $TestModel = new Author();
     $this->assertEquals(4, $TestModel->find('count'));
     $TestModel->deleteAll(true, false, false);
     $this->assertEquals(0, $TestModel->find('count'));
     $result = $TestModel->save();
     $this->assertTrue(isset($result['Author']['created']));
     $this->assertTrue(isset($result['Author']['updated']));
     $this->assertEquals(1, $TestModel->find('count'));
 }
开发者ID:manzapanza,项目名称:cakephp-api-utils,代码行数:17,代码来源:ModelWriteTest.php

示例13: testValidatesWithModelsAndSaveAllWithoutId

 /**
  * test that saveAll and with models at initial insert (no id has set yet)
  * with validation interact well
  *
  * @return void
  */
 public function testValidatesWithModelsAndSaveAllWithoutId()
 {
     $this->loadFixtures('Post', 'Author');
     $data = array('Author' => array('name' => 'Foo Bar'), 'Post' => array(array('title' => 'Hello'), array('title' => 'World')));
     $Author = new Author();
     $Post = $Author->Post;
     $Post->validate = array('author_id' => array('rule' => 'numeric'));
     $Author->create();
     $result = $Author->saveAll($data, array('validate' => 'only'));
     $this->assertTrue($result);
     $result = $Author->validateAssociated($data);
     $this->assertTrue($result);
     $this->assertTrue($result);
     $Author->create();
     $result = $Author->saveAll($data, array('validate' => 'first'));
     $this->assertTrue($result);
     $this->assertNotNull($Author->id);
     $id = $Author->id;
     $count = $Author->find('count', array('conditions' => array('Author.id' => $id)));
     $this->assertSame(1, $count);
     $count = $Post->find('count', array('conditions' => array('Post.author_id' => $id)));
     $this->assertEquals($count, count($data['Post']));
 }
开发者ID:kuradakis,项目名称:cakephp-ex,代码行数:29,代码来源:ModelValidationTest.php

示例14: testFindByDatetime

 public function testFindByDatetime()
 {
     $now = new DateTime();
     $arnow = new ActiveRecord\DateTime();
     $arnow->setTimestamp($now->getTimestamp());
     Author::find(1)->updateAttribute('created_at', $now);
     $this->assertNotNull(Author::findByCreatedAt($now));
     $this->assertNotNull(Author::findByCreatedAt($arnow));
 }
开发者ID:ruri,项目名称:php-activerecord-camelcased,代码行数:9,代码来源:ActiveRecordFindTest.php

示例15: testSetDateFlagsDirtyWithPhpDatetime

 public function testSetDateFlagsDirtyWithPhpDatetime()
 {
     $author = Author::create(array('some_date' => new \DateTime()));
     $author = Author::find($author->id);
     $author->some_date->setDate(2010, 1, 1);
     $this->assertHasKeys('some_date', $author->dirtyAttributes());
 }
开发者ID:ruri,项目名称:php-activerecord-camelcased,代码行数:7,代码来源:ActiveRecordWriteTest.php


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