本文整理汇总了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);
}
}
示例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);
}
示例3: runAuthorInsertion
function runAuthorInsertion($i)
{
$author = new Author();
$author->setFirstName('John' . $i);
$author->setLastName('Doe' . $i);
$author->save($this->con);
$this->authors[] = $author->getId();
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
示例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);
}
示例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());
}
示例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);
}
示例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;
}
示例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');
}
示例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");
}
示例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);
示例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())));
}