當前位置: 首頁>>代碼示例>>PHP>>正文


PHP BookQuery::setModelAlias方法代碼示例

本文整理匯總了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;
 }
開發者ID:dracony,項目名稱:forked-php-orm-benchmark,代碼行數:22,代碼來源:BaseBookQuery.php

示例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');
     }
 }
開發者ID:dracony,項目名稱:forked-php-orm-benchmark,代碼行數:19,代碼來源:PropelQueryTest.php

示例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());
 }
開發者ID:shelsonjava,項目名稱:datawrapper,代碼行數:9,代碼來源:QueryBuilderTest.php


注:本文中的BookQuery::setModelAlias方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。