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


PHP ParameterContainer::offsetSetReference方法代码示例

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


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

示例1: processLimitOffset

 /**
  * @param PlatformInterface $platform
  * @param DriverInterface $driver
  * @param ParameterContainer $parameterContainer
  * @param $sqls
  * @param $parameters
  * @return null
  */
 protected function processLimitOffset(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null, &$sqls, &$parameters)
 {
     if ($this->limit === null && $this->offset === null) {
         return;
     }
     $selectParameters = $parameters[self::SELECT];
     /** if this is a DISTINCT query then real SELECT part goes to second element in array **/
     $parameterIndex = 0;
     if ($selectParameters[0] === 'DISTINCT') {
         unset($selectParameters[0]);
         $selectParameters = array_values($selectParameters);
         $parameterIndex = 1;
     }
     $starSuffix = $platform->getIdentifierSeparator() . self::SQL_STAR;
     foreach ($selectParameters[0] as $i => $columnParameters) {
         if ($columnParameters[0] == self::SQL_STAR || isset($columnParameters[1]) && $columnParameters[1] == self::SQL_STAR || strpos($columnParameters[0], $starSuffix)) {
             $selectParameters[0] = [[self::SQL_STAR]];
             break;
         }
         if (isset($columnParameters[1])) {
             array_shift($columnParameters);
             $selectParameters[0][$i] = $columnParameters;
         }
     }
     // first, produce column list without compound names (using the AS portion only)
     array_unshift($sqls, $this->createSqlFromSpecificationAndParameters(['SELECT %1$s FROM (' => current($this->specifications[self::SELECT])], $selectParameters));
     if ($parameterContainer) {
         // create bottom part of query, with offset and limit using row_number
         $limitParamName = $driver->formatParameterName('limit');
         $offsetParamName = $driver->formatParameterName('offset');
         $offsetForSumParamName = $driver->formatParameterName('offsetForSum');
         array_push($sqls, ') AS [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION] WHERE [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION].[__ZEND_ROW_NUMBER] BETWEEN ' . $offsetParamName . '+1 AND ' . $limitParamName . '+' . $offsetForSumParamName);
         $parameterContainer->offsetSet('offset', $this->offset);
         $parameterContainer->offsetSet('limit', $this->limit);
         $parameterContainer->offsetSetReference('offsetForSum', 'offset');
     } else {
         array_push($sqls, ') AS [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION] WHERE [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION].[__ZEND_ROW_NUMBER] BETWEEN ' . (int) $this->offset . '+1 AND ' . (int) $this->limit . '+' . (int) $this->offset);
     }
     if (isset($sqls[self::ORDER])) {
         $orderBy = $sqls[self::ORDER];
         unset($sqls[self::ORDER]);
     } else {
         $orderBy = 'ORDER BY (SELECT 1)';
     }
     // add a column for row_number() using the order specification
     $parameters[self::SELECT][$parameterIndex][] = ['ROW_NUMBER() OVER (' . $orderBy . ')', '[__ZEND_ROW_NUMBER]'];
     $sqls[self::SELECT] = $this->createSqlFromSpecificationAndParameters($this->specifications[self::SELECT], $parameters[self::SELECT]);
 }
开发者ID:zendframework,项目名称:zend-db,代码行数:56,代码来源:SelectDecorator.php

示例2: processLimitOffset

 /**
  * @param PlatformInterface $platform
  * @param Adapter $adapter
  * @param ParameterContainer $parameterContainer
  * @param $sqls
  * @param $parameters
  * @return null
  */
 protected function processLimitOffset(PlatformInterface $platform, Adapter $adapter = null, ParameterContainer $parameterContainer = null, &$sqls, &$parameters)
 {
     if ($this->limit === null && $this->offset === null) {
         return null;
     }
     $selectParameters = $parameters[self::SPECIFICATION_SELECT];
     $starSuffix = $platform->getIdentifierSeparator() . self::SQL_STAR;
     foreach ($selectParameters[0] as $i => $columnParameters) {
         if ($columnParameters[0] == self::SQL_STAR || isset($columnParameters[1]) && $columnParameters[1] == self::SQL_STAR || strpos($columnParameters[0], $starSuffix)) {
             $selectParameters[0] = array(array(self::SQL_STAR));
             break;
         }
         if (isset($columnParameters[1])) {
             array_shift($columnParameters);
             $selectParameters[0][$i] = $columnParameters;
         }
     }
     // first, produce column list without compound names (using the AS portion only)
     array_unshift($sqls, $this->createSqlFromSpecificationAndParameters(array('SELECT %1$s FROM (' => current($this->specifications[self::SPECIFICATION_SELECT])), $selectParameters));
     if ($parameterContainer) {
         // create bottom part of query, with offset and limit using row_number
         array_push($sqls, ') AS [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION] WHERE [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION].[__ZEND_ROW_NUMBER] BETWEEN ?+1 AND ?+?');
         $parameterContainer->offsetSet('offset', $this->offset);
         $parameterContainer->offsetSet('limit', $this->limit);
         $parameterContainer->offsetSetReference('offsetForSum', 'offset');
     } else {
         array_push($sqls, ') AS [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION] WHERE [ZEND_SQL_SERVER_LIMIT_OFFSET_EMULATION].[__ZEND_ROW_NUMBER] BETWEEN ' . (int) $this->offset . '+1 AND ' . (int) $this->limit . '+' . (int) $this->offset);
     }
     if (isset($sqls[self::SPECIFICATION_ORDER])) {
         $orderBy = $sqls[self::SPECIFICATION_ORDER];
         unset($sqls[self::SPECIFICATION_ORDER]);
     } else {
         $orderBy = 'SELECT 1';
     }
     // add a column for row_number() using the order specification
     $parameters[self::SPECIFICATION_SELECT][0][] = array('ROW_NUMBER() OVER (' . $orderBy . ')', '[__ZEND_ROW_NUMBER]');
     $sqls[self::SPECIFICATION_SELECT] = $this->createSqlFromSpecificationAndParameters($this->specifications[self::SPECIFICATION_SELECT], $parameters[self::SPECIFICATION_SELECT]);
 }
开发者ID:rikaix,项目名称:zf2,代码行数:46,代码来源:SelectDecorator.php


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