本文整理匯總了PHP中Propel\Tests\Bookstore\BookQuery::setModelAlias方法的典型用法代碼示例。如果您正苦於以下問題:PHP BookQuery::setModelAlias方法的具體用法?PHP BookQuery::setModelAlias怎麽用?PHP BookQuery::setModelAlias使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Propel\Tests\Bookstore\BookQuery
的用法示例。
在下文中一共展示了BookQuery::setModelAlias方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testFrom
public function testFrom()
{
$q = PropelQuery::from('\\Propel\\Tests\\Bookstore\\Book');
$expected = new BookQuery();
$this->assertEquals($expected, $q, 'from() returns a Model query instance based on the model name');
$q = PropelQuery::from('\\Propel\\Tests\\Bookstore\\Book b');
$expected = new BookQuery();
$expected->setModelAlias('b');
$this->assertEquals($expected, $q, 'from() sets the model alias if found after the blank');
$q = PropelQuery::from('\\Propel\\Tests\\Runtime\\Query\\myBook');
$expected = new myBookQuery();
$this->assertEquals($expected, $q, 'from() can find custom query classes');
try {
$q = PropelQuery::from('Foo');
$this->fail('PropelQuery::from() throws an exception when called on a non-existing query class');
} catch (PropelException $e) {
$this->assertTrue(true, 'PropelQuery::from() throws an exception when called on a non-existing query class');
}
}
示例2: testQuery
public function testQuery()
{
BookstoreDataPopulator::depopulate();
BookstoreDataPopulator::populate();
$q = new BookQuery();
$book = $q->setModelAlias('b')->where('b.Title like ?', 'Don%')->orderBy('b.ISBN', 'desc')->findOne();
$this->assertTrue($book instanceof Book);
$this->assertEquals('Don Juan', $book->getTitle());
}