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


PHP Author::getId方法代码示例

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


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

示例1: showLinkToSelf

 /**
  * @param string $mode
  *
  * @return string
  */
 public function showLinkToSelf($mode = '')
 {
     $url = '?p=author&id=';
     $mode_url = '&m=' . $mode;
     if (empty($mode)) {
         return $this->html($url . $this->author->getId());
     } else {
         return $this->html($url . $this->author->getId() . $mode_url);
     }
 }
开发者ID:arkuuu,项目名称:publin,代码行数:15,代码来源:AuthorView.php

示例2: testFromArray

 public function testFromArray()
 {
     $author = new Author();
     $author->setFirstName('Jane');
     $author->setLastName('Austen');
     $author->save();
     $books = array(array('Title' => 'Mansfield Park', 'AuthorId' => $author->getId()), array('Title' => 'Pride And PRejudice', 'AuthorId' => $author->getId()));
     $col = new PropelObjectCollection();
     $col->setModel('Book');
     $col->fromArray($books);
     $col->save();
     $nbBooks = PropelQuery::from('Book')->count();
     $this->assertEquals(6, $nbBooks);
     $booksByJane = PropelQuery::from('Book b')->join('b.Author a')->where('a.LastName = ?', 'Austen')->count();
     $this->assertEquals(2, $booksByJane);
 }
开发者ID:keneanung,项目名称:gw2spidy,代码行数:16,代码来源:PropelObjectCollectionWithFixturesTest.php

示例3: runAuthorInsertion

 function runAuthorInsertion($i)
 {
     $author = new Author();
     $author->setFirstName('John' . $i);
     $author->setLastName('Doe' . $i);
     $author->save($this->con);
     $this->authors[] = $author->getId();
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:8,代码来源:Propel17TestSuite.php

示例4: Author

 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: testGetId

 function testGetId()
 {
     //Arrange
     $author_name = "J.K. Rowling";
     $id = 1;
     $test_author = new Author($author_name, $id);
     //Act
     $result = $test_author->getId();
     //Assert
     $this->assertEquals(1, $result);
 }
开发者ID:jtorrespdx,项目名称:library_catalog,代码行数:11,代码来源:AuthorTest.php

示例7: testGetId

 function testGetId()
 {
     //Arrange
     $first_name = "J.K.";
     $last_name = "Rowling";
     $test_author = new Author($first_name, $last_name);
     $test_author->save();
     //Act
     $result = $test_author->getId();
     //Assert
     $this->assertEquals(true, is_numeric($result));
 }
开发者ID:jtorrespdx,项目名称:library,代码行数:12,代码来源:AuthorTest.php

示例8: 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

示例9: testSavingParentSavesRelatedObjectsIncludingNew

 public function testSavingParentSavesRelatedObjectsIncludingNew()
 {
     $author = AuthorPeer::retrieveByPK($this->author->getId());
     // add new object before fetching old books
     $b3 = new Book();
     $author->addBook($b3);
     $c = new Criteria();
     $c->add(BookPeer::ID, $this->books[0]->getId());
     $books = $author->getBooks($c);
     $books[0]->setTitle('Update to a book');
     $author->save();
     $this->assertEquals(3, $author->countBooks());
     $this->assertFalse($b3->isModified());
     $this->assertFalse($books[0]->isModified());
 }
开发者ID:kcornejo,项目名称:estadistica,代码行数:15,代码来源:PoisonedCacheBugTest.php

示例10: 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

示例11: save

 public function save($data)
 {
     $ret = parent::save($data);
     if (isset($data['author'])) {
         $id = $this->getId();
         $authors = explode(";", $data['author']);
         foreach ($authors as $author) {
             $a = new Author();
             $a->setName($author);
             $a->commit();
             $bookAuthor = new BookAuthor();
             $bookAuthor->setBookId($id);
             $bookAuthor->setAuthorId($a->getId());
             $bookAuthor->commit();
         }
     }
     return $ret;
 }
开发者ID:manishkhanchandani,项目名称:mkgxy,代码行数:18,代码来源:Book.php

示例12: testFindOneWithDuplicateRelation

 public function testFindOneWithDuplicateRelation()
 {
     EssayPeer::doDeleteAll();
     $auth1 = new Author();
     $auth1->setFirstName('John');
     $auth1->save();
     $auth2 = new Author();
     $auth2->setFirstName('Jack');
     $auth2->save();
     $essay = new Essay();
     $essay->setTitle('Foo');
     $essay->setFirstAuthor($auth1->getId());
     $essay->setSecondAuthor($auth2->getId());
     $essay->save();
     AuthorPeer::clearInstancePool();
     EssayPeer::clearInstancePool();
     $c = new ModelCriteria('bookstore', 'Essay');
     $c->join('Essay.AuthorRelatedByFirstAuthor');
     $c->with('AuthorRelatedByFirstAuthor');
     $c->where('Essay.Title = ?', 'Foo');
     $con = Propel::getConnection(BookPeer::DATABASE_NAME);
     $essay = $c->findOne($con);
     $count = $con->getQueryCount();
     $this->assertEquals($essay->getTitle(), 'Foo', 'Main object is correctly hydrated');
     $firstAuthor = $essay->getAuthorRelatedByFirstAuthor();
     $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query');
     $this->assertEquals($firstAuthor->getFirstName(), 'John', 'Related object is correctly hydrated');
     $secondAuthor = $essay->getAuthorRelatedBySecondAuthor();
     $this->assertEquals($count + 1, $con->getQueryCount(), 'with() does not hydrate objects not in with');
 }
开发者ID:halfer,项目名称:Meshing,代码行数:30,代码来源:PropelObjectFormatterWithTest.php

示例13: testNestedTransactionForceRollBack

 public function testNestedTransactionForceRollBack()
 {
     $con = Propel::getConnection(BookPeer::DATABASE_NAME);
     $driver = $con->getAttribute(PDO::ATTR_DRIVER_NAME);
     // main transaction
     $con->beginTransaction();
     $a = new Author();
     $a->setFirstName('Test');
     $a->setLastName('User');
     $a->save($con);
     $authorId = $a->getId();
     // nested transaction
     $con->beginTransaction();
     $a2 = new Author();
     $a2->setFirstName('Test2');
     $a2->setLastName('User2');
     $a2->save($con);
     $authorId2 = $a2->getId();
     // force rollback
     $con->forceRollback();
     $this->assertEquals(0, $con->getNestedTransactionCount(), 'nested transaction is null after nested transaction forced rollback');
     $this->assertFalse($con->isInTransaction(), 'PropelPDO is not in transaction after nested transaction force rollback');
     AuthorPeer::clearInstancePool();
     $at = AuthorPeer::retrieveByPK($authorId);
     $this->assertNull($at, "Rolled back transaction is not persisted in database");
     $at2 = AuthorPeer::retrieveByPK($authorId2);
     $this->assertNull($at2, "Forced Rolled back nested transaction is not persisted in database");
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:28,代码来源:PropelPDOTest.php

示例14: Author

    $stephenson->setFirstName("Neal");
    $stephenson->setLastName("Stephenson");
    $stephenson->save();
    $stephenson_id = $stephenson->getId();
    print "Added author \"Neal Stephenson\" [id = {$stephenson_id}].\n";
    $byron = new Author();
    $byron->setFirstName("George");
    $byron->setLastName("Byron");
    $byron->save();
    $byron_id = $byron->getId();
    print "Added author \"George Byron\" [id = {$byron_id}].\n";
    $grass = new Author();
    $grass->setFirstName("Gunter");
    $grass->setLastName("Grass");
    $grass->save();
    $grass_id = $grass->getId();
    print "Added author \"Gunter Grass\" [id = {$grass_id}].\n";
} catch (Exception $e) {
    die("Error adding author: " . $e->__toString());
}
// Add book records
// ----------------
try {
    print "\nAdding some new books to the list\n";
    print "-------------------------------------\n\n";
    $phoenix = new Book();
    $phoenix->setTitle("Harry Potter and the Order of the Phoenix");
    $phoenix->setISBN("043935806X");
    print "Trying cascading save (Harry Potter): ";
    $phoenix->setAuthor($rowling);
    $phoenix->setPublisher($scholastic);
开发者ID:yasirgit,项目名称:afids,代码行数:31,代码来源:bookstore-test.php

示例15: isBlogAuthor

 /**
  * Test if author is blog author
  *
  * @param Author $author
  * @param Article $blogInfo
  * @return bool
  */
 public function isBlogAuthor(\Author $author, \Article $blogInfo)
 {
     return in_array($author->getId(), array_map(function ($blogAuthor) {
         return $blogAuthor->getId();
     }, \ArticleAuthor::GetAuthorsByArticle($blogInfo->getArticleNumber(), $blogInfo->getLanguageId())));
 }
开发者ID:nidzix,项目名称:Newscoop,代码行数:13,代码来源:BlogService.php


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