当前位置: 首页>>代码示例>>PHP>>正文


PHP BasePeer::needsSelectAliases方法代码示例

本文整理汇总了PHP中BasePeer::needsSelectAliases方法的典型用法代码示例。如果您正苦于以下问题:PHP BasePeer::needsSelectAliases方法的具体用法?PHP BasePeer::needsSelectAliases怎么用?PHP BasePeer::needsSelectAliases使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BasePeer的用法示例。


在下文中一共展示了BasePeer::needsSelectAliases方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testNeedsSelectAliases

 public function testNeedsSelectAliases()
 {
     $c = new Criteria();
     $this->assertFalse(BasePeer::needsSelectAliases($c), 'Empty Criterias dont need aliases');
     $c = new Criteria();
     $c->addSelectColumn(BookPeer::ID);
     $c->addSelectColumn(BookPeer::TITLE);
     $this->assertFalse(BasePeer::needsSelectAliases($c), 'Criterias with distinct column names dont need aliases');
     $c = new Criteria();
     BookPeer::addSelectColumns($c);
     $this->assertFalse(BasePeer::needsSelectAliases($c), 'Criterias with only the columns of a model dont need aliases');
     $c = new Criteria();
     $c->addSelectColumn(BookPeer::ID);
     $c->addSelectColumn(AuthorPeer::ID);
     $this->assertTrue(BasePeer::needsSelectAliases($c), 'Criterias with common column names do need aliases');
 }
开发者ID:halfer,项目名称:Meshing,代码行数:16,代码来源:BasePeerTest.php

示例2: doCount

 protected function doCount($con)
 {
     $dbMap = Propel::getDatabaseMap($this->getDbName());
     $db = Propel::getDB($this->getDbName());
     // check that the columns of the main class are already added (if this is the primary ModelCriteria)
     if (!$this->hasSelectClause() && !$this->getPrimaryCriteria()) {
         $this->addSelfSelectColumns();
     }
     $this->configureSelectColumns();
     $needsComplexCount = $this->getGroupByColumns() || $this->getOffset() || $this->getLimit() || $this->getHaving() || in_array(Criteria::DISTINCT, $this->getSelectModifiers()) || count($this->selectQueries) > 0;
     $params = array();
     if ($needsComplexCount) {
         if (BasePeer::needsSelectAliases($this)) {
             if ($this->getHaving()) {
                 throw new PropelException('Propel cannot create a COUNT query when using HAVING and  duplicate column names in the SELECT part');
             }
             $db->turnSelectColumnsToAliases($this);
         }
         $selectSql = BasePeer::createSelectSql($this, $params);
         $sql = 'SELECT COUNT(*) FROM (' . $selectSql . ') propelmatch4cnt';
     } else {
         // Replace SELECT columns with COUNT(*)
         $this->clearSelectColumns()->addSelectColumn('COUNT(*)');
         $sql = BasePeer::createSelectSql($this, $params);
     }
     try {
         $stmt = $con->prepare($sql);
         $db->bindValues($stmt, $params, $dbMap);
         $stmt->execute();
     } catch (Exception $e) {
         Propel::log($e->getMessage(), Propel::LOG_ERR);
         throw new PropelException(sprintf('Unable to execute COUNT statement [%s]', $sql), $e);
     }
     return $stmt;
 }
开发者ID:kcornejo,项目名称:estadistica,代码行数:35,代码来源:ModelCriteria.php

示例3: applyLimit

 /**
  * @see       DBAdapter::applyLimit()
  *
  * @param     string   $sql
  * @param     integer  $offset
  * @param     integer  $limit
  * @param     null|Criteria  $criteria
  */
 public function applyLimit(&$sql, $offset, $limit, $criteria = null)
 {
     if (BasePeer::needsSelectAliases($criteria)) {
         $crit = clone $criteria;
         $selectSql = $this->createSelectSqlPart($crit, $params, true);
         $sql = $selectSql . substr($sql, strpos($sql, 'FROM') - 1);
     }
     $sql = 'SELECT B.* FROM (' . 'SELECT A.*, rownum AS PROPEL_ROWNUM FROM (' . $sql . ') A ' . ') B WHERE ';
     if ($offset > 0) {
         $sql .= ' B.PROPEL_ROWNUM > ' . $offset;
         if ($limit > 0) {
             $sql .= ' AND B.PROPEL_ROWNUM <= ' . ($offset + $limit);
         }
     } else {
         $sql .= ' B.PROPEL_ROWNUM <= ' . $limit;
     }
 }
开发者ID:ketheriel,项目名称:ETVA,代码行数:25,代码来源:DBOracle.php

示例4: getCountStatement

 protected function getCountStatement($con = null)
 {
     $dbMap = Propel::getDatabaseMap($this->getDbName());
     $db = Propel::getDB($this->getDbName());
     if ($con === null) {
         $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
     }
     // check that the columns of the main class are already added (if this is the primary ModelCriteria)
     if (!$this->hasSelectClause() && !$this->getPrimaryCriteria()) {
         $this->addSelfSelectColumns();
     }
     $needsComplexCount = $this->getGroupByColumns() || $this->getOffset() || $this->getLimit() || $this->getHaving() || in_array(Criteria::DISTINCT, $this->getSelectModifiers());
     $con->beginTransaction();
     try {
         $this->basePreSelect($con);
         $params = array();
         if ($needsComplexCount) {
             if (BasePeer::needsSelectAliases($this)) {
                 if ($this->getHaving()) {
                     throw new PropelException('Propel cannot create a COUNT query when using HAVING and  duplicate column names in the SELECT part');
                 }
                 BasePeer::turnSelectColumnsToAliases($this);
             }
             $selectSql = BasePeer::createSelectSql($this, $params);
             $sql = 'SELECT COUNT(*) FROM (' . $selectSql . ') propelmatch4cnt';
         } else {
             // Replace SELECT columns with COUNT(*)
             $this->clearSelectColumns()->addSelectColumn('COUNT(*)');
             $sql = BasePeer::createSelectSql($this, $params);
         }
         $stmt = $con->prepare($sql);
         BasePeer::populateStmtValues($stmt, $params, $dbMap, $db);
         $stmt->execute();
         $con->commit();
     } catch (PropelException $e) {
         $con->rollback();
         throw $e;
     }
     return $stmt;
 }
开发者ID:sanemat,项目名称:bllik,代码行数:40,代码来源:ModelCriteria.php


注:本文中的BasePeer::needsSelectAliases方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。