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


PHP Criteria::setDistinct方法代碼示例

本文整理匯總了PHP中Propel\Runtime\ActiveQuery\Criteria::setDistinct方法的典型用法代碼示例。如果您正苦於以下問題:PHP Criteria::setDistinct方法的具體用法?PHP Criteria::setDistinct怎麽用?PHP Criteria::setDistinct使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Propel\Runtime\ActiveQuery\Criteria的用法示例。


在下文中一共展示了Criteria::setDistinct方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testMultipleFunctionInCriteria

 /**
  * @link http://propel.phpdb.org/trac/ticket/425
  */
 public function testMultipleFunctionInCriteria()
 {
     $db = Propel::getServiceContainer()->getAdapter(BookTableMap::DATABASE_NAME);
     try {
         $c = new Criteria();
         $c->setDistinct();
         if ($db instanceof PgsqlAdapter) {
             $c->addSelectColumn("substring(" . BookTableMap::TITLE . " from position('Potter' in " . BookTableMap::TITLE . ")) AS col");
         } else {
             $this->markTestSkipped('Configured database vendor is not PostgreSQL');
         }
         $obj = BookQuery::create(null, $c)->find();
     } catch (PropelException $x) {
         $this->fail("Paring of nested functions failed: " . $x->getMessage());
     }
 }
開發者ID:bondarovich,項目名稱:Propel2,代碼行數:19,代碼來源:TableMapTest.php

示例2: testCreateSelectSqlPartSelectModifier

 public function testCreateSelectSqlPartSelectModifier()
 {
     $db = Propel::getServiceContainer()->getAdapter(BookTableMap::DATABASE_NAME);
     $c = new Criteria();
     $c->addSelectColumn(BookTableMap::COL_ID);
     $c->addAsColumn('book_id', BookTableMap::COL_ID);
     $c->setDistinct();
     $fromClause = [];
     $selectSql = $db->createSelectSqlPart($c, $fromClause);
     $this->assertEquals('SELECT DISTINCT book.id, book.id AS book_id', $selectSql, 'createSelectSqlPart() includes the select modifiers in the SELECT clause');
     $this->assertEquals(['book'], $fromClause, 'createSelectSqlPart() adds the tables from the select columns to the from clause');
 }
開發者ID:disider,項目名稱:Propel2,代碼行數:12,代碼來源:AbstractAdapterTest.php

示例3: testAddSelectModifier

 public function testAddSelectModifier()
 {
     $c = new Criteria();
     $c->setDistinct();
     $c->addSelectModifier('SQL_CALC_FOUND_ROWS');
     $this->assertEquals(array(Criteria::DISTINCT, 'SQL_CALC_FOUND_ROWS'), $c->getSelectModifiers(), 'addSelectModifier() adds a select modifier to the Criteria');
     $c->addSelectModifier('SQL_CALC_FOUND_ROWS');
     $this->assertEquals(array(Criteria::DISTINCT, 'SQL_CALC_FOUND_ROWS'), $c->getSelectModifiers(), 'addSelectModifier() adds a select modifier only once');
     $params = array();
     $result = $c->createSelectSql($params);
     $this->assertEquals('SELECT DISTINCT SQL_CALC_FOUND_ROWS  FROM ', $result, 'addSelectModifier() adds a modifier to the final query');
 }
開發者ID:robin850,項目名稱:Propel2,代碼行數:12,代碼來源:CriteriaTest.php

示例4: testMergeWithSelectModifiers

 public function testMergeWithSelectModifiers()
 {
     $c1 = new Criteria();
     $c1->setDistinct();
     $c2 = new Criteria();
     $c1->mergeWith($c2);
     $this->assertEquals(array(Criteria::DISTINCT), $c1->getSelectModifiers(), 'mergeWith() does not remove an existing select modifier');
     $c1 = new Criteria();
     $c2 = new Criteria();
     $c2->setDistinct();
     $c1->mergeWith($c2);
     $this->assertEquals(array(Criteria::DISTINCT), $c1->getSelectModifiers(), 'mergeWith() merges the select modifiers');
     $c1 = new Criteria();
     $c1->setDistinct();
     $c2 = new Criteria();
     $c2->setDistinct();
     $c1->mergeWith($c2);
     $this->assertEquals(array(Criteria::DISTINCT), $c1->getSelectModifiers(), 'mergeWith() does not duplicate select modifiers');
     $c1 = new Criteria();
     $c1->setAll();
     $c2 = new Criteria();
     $c2->setDistinct();
     $c1->mergeWith($c2);
     $this->assertEquals(array(Criteria::ALL), $c1->getSelectModifiers(), 'mergeWith() does not merge the select modifiers in case of conflict');
 }
開發者ID:bondarovich,項目名稱:Propel2,代碼行數:25,代碼來源:CriteriaMergeTest.php


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