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


PHP Criteria::clearSelectColumns方法代碼示例

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


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

示例1: testAddJoinMultipleWithJoinTypeAndOperator

 /**
  * Test the Criteria::addJoinMultiple() method with join type and operator
  *
  * @link       http://propel.phpdb.org/trac/ticket/606
  */
 public function testAddJoinMultipleWithJoinTypeAndOperator()
 {
     $c = new Criteria();
     $c->clearSelectColumns()->addMultipleJoin(array(array('TABLE_A.FOO_ID', 'TABLE_B.ID', Criteria::GREATER_EQUAL), array('TABLE_A.BAR', 'TABLE_B.BAZ', Criteria::LESS_THAN)), Criteria::LEFT_JOIN)->addSelectColumn("TABLE_A.ID");
     $expect = 'SELECT TABLE_A.ID FROM TABLE_A ' . 'LEFT JOIN TABLE_B ON (TABLE_A.FOO_ID>=TABLE_B.ID AND TABLE_A.BAR<TABLE_B.BAZ)';
     $params = array();
     $result = $c->createSelectSql($params);
     $this->assertEquals($expect, $result);
 }
開發者ID:robin850,項目名稱:Propel2,代碼行數:14,代碼來源:CriteriaTest.php

示例2: turnSelectColumnsToAliases

 /**
  * Ensures uniqueness of select column names by turning them all into aliases
  * This is necessary for queries on more than one table when the tables share a column name
  *
  * @see http://propel.phpdb.org/trac/ticket/795
  *
  * @param  Criteria $criteria
  * @return Criteria The input, with Select columns replaced by aliases
  */
 public function turnSelectColumnsToAliases(Criteria $criteria)
 {
     $selectColumns = $criteria->getSelectColumns();
     // clearSelectColumns also clears the aliases, so get them too
     $asColumns = $criteria->getAsColumns();
     $criteria->clearSelectColumns();
     $columnAliases = $asColumns;
     // add the select columns back
     foreach ($selectColumns as $clause) {
         // Generate a unique alias
         $baseAlias = preg_replace('/\\W/', '_', $clause);
         $alias = $baseAlias;
         // If it already exists, add a unique suffix
         $i = 0;
         while (isset($columnAliases[$alias])) {
             $i++;
             $alias = $baseAlias . '_' . $i;
         }
         // Add it as an alias
         $criteria->addAsColumn($alias, $clause);
         $columnAliases[$alias] = $clause;
     }
     // Add the aliases back, don't modify them
     foreach ($asColumns as $name => $clause) {
         $criteria->addAsColumn($name, $clause);
     }
     return $criteria;
 }
開發者ID:bondarovich,項目名稱:Propel2,代碼行數:37,代碼來源:PdoAdapter.php

示例3: testAddJoinMultipleWithJoinTypeAndOperator

 /**
  * Test the Criteria::addJoinMultiple() method with join type and operator
  *
  * @link       http://propel.phpdb.org/trac/ticket/606
  */
 public function testAddJoinMultipleWithJoinTypeAndOperator()
 {
     $c = new Criteria();
     $c->clearSelectColumns()->addMultipleJoin([['TABLE_A.FOO_ID', 'TABLE_B.id', Criteria::GREATER_EQUAL], ['TABLE_A.BAR', 'TABLE_B.BAZ', Criteria::LESS_THAN]], Criteria::LEFT_JOIN)->addSelectColumn("TABLE_A.id");
     $expect = $this->getSql('SELECT TABLE_A.id FROM TABLE_A ' . 'LEFT JOIN TABLE_B ON (TABLE_A.FOO_ID>=TABLE_B.id AND TABLE_A.BAR<TABLE_B.BAZ)');
     $params = [];
     $result = $c->createSelectSql($params);
     $this->assertEquals($expect, $result);
 }
開發者ID:naldz,項目名稱:cyberden,代碼行數:14,代碼來源:CriteriaTest.php


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