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


PHP SQLSelect::getLimit方法代码示例

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


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

示例1: buildLimitFragment

 /**
  * Return the LIMIT clause ready for inserting into a query.
  *
  * @param SQLSelect $query The expression object to build from
  * @param array $parameters Out parameter for the resulting query parameters
  * @return string The finalised limit SQL fragment
  */
 public function buildLimitFragment(SQLSelect $query, array &$parameters)
 {
     $nl = $this->getSeparator();
     // Ensure limit is given
     $limit = $query->getLimit();
     if (empty($limit)) {
         return '';
     }
     // For literal values return this as the limit SQL
     if (!is_array($limit)) {
         return "{$nl}LIMIT {$limit}";
     }
     // Assert that the array version provides the 'limit' key
     if (!array_key_exists('limit', $limit) || $limit['limit'] !== null && !is_numeric($limit['limit'])) {
         throw new InvalidArgumentException('SQLite3QueryBuilder::buildLimitSQL(): Wrong format for $limit: ' . var_export($limit, true));
     }
     $clause = "{$nl}";
     if ($limit['limit'] !== null) {
         $clause .= "LIMIT {$limit['limit']} ";
     } else {
         $clause .= "LIMIT -1 ";
     }
     if (isset($limit['start']) && is_numeric($limit['start']) && $limit['start'] !== 0) {
         $clause .= "OFFSET {$limit['start']}";
     }
     return $clause;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-sqlite3,代码行数:34,代码来源:SQLite3QueryBuilder.php

示例2: testLimitSetFromClauseString

 /**
  * Test passing in a LIMIT with OFFSET clause string.
  */
 public function testLimitSetFromClauseString()
 {
     $query = new SQLSelect();
     $query->setSelect('*');
     $query->setFrom('"SQLSelectTest_DO"');
     $query->setLimit('20 OFFSET 10');
     $limit = $query->getLimit();
     $this->assertEquals(20, $limit['limit']);
     $this->assertEquals(10, $limit['start']);
 }
开发者ID:assertchris,项目名称:silverstripe-framework,代码行数:13,代码来源:SQLSelectTest.php

示例3: setPaginationFromQuery

 /**
  * Sets the page length, page start and total items from a query object's
  * limit, offset and unlimited count. The query MUST have a limit clause.
  *
  * @param SQLSelect $query
  */
 public function setPaginationFromQuery(SQLSelect $query)
 {
     if ($limit = $query->getLimit()) {
         $this->setPageLength($limit['limit']);
         $this->setPageStart($limit['start']);
         $this->setTotalItems($query->unlimitedRowCount());
     }
     return $this;
 }
开发者ID:congaaids,项目名称:silverstripe-framework,代码行数:15,代码来源:PaginatedList.php

示例4: parseLimit

 /**
  * Extracts the limit and offset from the limit clause
  * 
  * @param SQLSelect $query
  * @return array Two item array with $limit and $offset as values
  * @throws InvalidArgumentException
  */
 protected function parseLimit(SQLSelect $query)
 {
     $limit = '';
     $offset = '0';
     if (is_array($query->getLimit())) {
         $limitArr = $query->getLimit();
         if (isset($limitArr['limit'])) {
             $limit = $limitArr['limit'];
         }
         if (isset($limitArr['start'])) {
             $offset = $limitArr['start'];
         }
     } else {
         if (preg_match('/^([0-9]+) offset ([0-9]+)$/i', trim($query->getLimit()), $matches)) {
             $limit = $matches[1];
             $offset = $matches[2];
         } else {
             //could be a comma delimited string
             $bits = explode(',', $query->getLimit());
             if (sizeof($bits) > 1) {
                 list($offset, $limit) = $bits;
             } else {
                 $limit = $bits[0];
             }
         }
     }
     return array($limit, $offset);
 }
开发者ID:helpfulrobot,项目名称:silverstripe-mssql,代码行数:35,代码来源:MSSQLQueryBuilder.php


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