本文整理汇总了PHP中BookQuery::setModelAlias方法的典型用法代码示例。如果您正苦于以下问题:PHP BookQuery::setModelAlias方法的具体用法?PHP BookQuery::setModelAlias怎么用?PHP BookQuery::setModelAlias使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BookQuery
的用法示例。
在下文中一共展示了BookQuery::setModelAlias方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* Returns a new BookQuery object.
*
* @param string $modelAlias The alias of a model in the query
* @param BookQuery|Criteria $criteria Optional Criteria to build the query from
*
* @return BookQuery
*/
public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof BookQuery) {
return $criteria;
}
$query = new BookQuery();
if (null !== $modelAlias) {
$query->setModelAlias($modelAlias);
}
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
}
示例2: testFrom
public function testFrom()
{
$q = PropelQuery::from('Book');
$expected = new BookQuery();
$this->assertEquals($expected, $q, 'from() returns a Model query instance based on the model name');
$q = PropelQuery::from('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('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');
}
}
示例3: 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());
}