本文整理汇总了PHP中AuthorPeer::doSelectOne方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthorPeer::doSelectOne方法的具体用法?PHP AuthorPeer::doSelectOne怎么用?PHP AuthorPeer::doSelectOne使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AuthorPeer
的用法示例。
在下文中一共展示了AuthorPeer::doSelectOne方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
protected function setUp()
{
parent::setUp();
BookstoreDataPopulator::populate();
$cr = new Criteria();
$cr->add(AuthorPeer::LAST_NAME, "Rowling");
$cr->add(AuthorPeer::FIRST_NAME, "J.K.");
$rowling = AuthorPeer::doSelectOne($cr);
$this->authorId = $rowling->getId();
$book = new Book();
$book->setTitle("Harry Potter and the Philosopher's Stone");
$book->setISBN("1234");
$book->setAuthor($rowling);
$book->save();
$this->books[] = $book->getId();
$book = new Book();
$book->setTitle("Harry Potter and the Chamber of Secrets");
$book->setISBN("1234");
$book->setAuthor($rowling);
$book->save();
$this->books[] = $book->getId();
$book = new Book();
$book->setTitle("Harry Potter and the Prisoner of Azkaban");
$book->setISBN("1234");
$book->setAuthor($rowling);
$book->save();
$this->books[] = $book->getId();
$book = new Book();
$book->setTitle("Harry Potter and the Goblet of Fire");
$book->setISBN("1234");
$book->setAuthor($rowling);
$book->save();
$this->books[] = $book->getId();
$book = new Book();
$book->setTitle("Harry Potter and the Half-Blood Prince");
$book->setISBN("1234");
$book->setAuthor($rowling);
$book->save();
$this->books[] = $book->getId();
$book = new Book();
$book->setTitle("Harry Potter and the Deathly Hallows");
$book->setISBN("1234");
$book->setAuthor($rowling);
$book->save();
$this->books[] = $book->getId();
}
示例2: testReloadDeep
/**
* Test reload(deep=true) method.
*/
public function testReloadDeep()
{
BookstoreDataPopulator::populate();
// arbitrary book
$b = BookPeer::doSelectOne(new Criteria());
// arbitrary, different author
$c = new Criteria();
$c->add(AuthorPeer::ID, $b->getAuthorId(), Criteria::NOT_EQUAL);
$a = AuthorPeer::doSelectOne($c);
$origAuthor = $b->getAuthor();
$b->setAuthor($a);
$this->assertNotEquals($origAuthor, $b->getAuthor(), "Expected just-set object to be different from obj from DB");
$this->assertTrue($b->isModified());
$b->reload($deep = true);
$this->assertEquals($origAuthor, $b->getAuthor(), "Expected object in DB to be restored");
$this->assertFalse($a->isModified());
}
示例3: testRefFKGetJoin
public function testRefFKGetJoin()
{
BookstoreDataPopulator::populate();
BookPeer::clearInstancePool();
AuthorPeer::clearInstancePool();
PublisherPeer::clearInstancePool();
$con = Propel::getConnection(BookPeer::DATABASE_NAME);
$author = AuthorPeer::doSelectOne(new Criteria(), $con);
// populate book instance pool
$books = $author->getBooksJoinPublisher(null, $con);
$sql = $con->getLastExecutedQuery();
$publisher = $books[0]->getPublisher($con);
$this->assertEquals($sql, $con->getLastExecutedQuery(), 'refFK getter uses instance pool if possible');
}
示例4: testAddJoinMultipleWithNotInOperator
public function testAddJoinMultipleWithNotInOperator()
{
$con = Propel::getConnection(BookPeer::DATABASE_NAME);
$c = new Criteria();
$c->addMultipleJoin(array(array(AuthorPeer::ID, BookPeer::AUTHOR_ID), array(BookPeer::ISBN, array(1, 7, 42), Criteria::NOT_IN)), Criteria::LEFT_JOIN);
AuthorPeer::doSelectOne($c, $con);
$expectedSQL = 'SELECT author.id, author.first_name, author.last_name, author.email, author.age FROM author LEFT JOIN book ON (author.id=book.author_id AND book.isbn NOT IN (1,7,42)) LIMIT 1';
$this->assertEquals($expectedSQL, $con->getLastExecutedQuery());
}
示例5: getAuthor
public function getAuthor(PropelPDO $con = null)
{
if ($this->aAuthor === null && $this->author_id !== null) {
$c = new Criteria(AuthorPeer::DATABASE_NAME);
$c->add(AuthorPeer::ID, $this->author_id);
$this->aAuthor = AuthorPeer::doSelectOne($c, $con);
}
return $this->aAuthor;
}