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


PHP SQLQuery::unlimitedRowCount方法代码示例

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


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

示例1: parseQueryLimit

	/**
	 * Use the limit from the given query to add prev/next buttons to this DataObjectSet.
	 * @param SQLQuery $query The query used to generate this DataObjectSet
	 */
	public function parseQueryLimit(SQLQuery $query) {
		if($query->limit) {
			if(stripos($query->limit, 'OFFSET')) {
				list($length, $start) = split(" +OFFSET +", trim($query->limit));
			} else {
				$result = split(" *, *", trim($query->limit));
				$start = $result[0];
				$length = isset($result[1]) ? $result[1] : null;
			}
			
			if(!$length) { 
				$length = $start;
				$start = 0;
			}	
			$this->setPageLimits($start, $length, $query->unlimitedRowCount());
		}
	}
开发者ID:neopba,项目名称:silverstripe-book,代码行数:21,代码来源:DataObjectSet.php

示例2: parseQueryLimit

 /**
  * Use the limit from the given query to add prev/next buttons to this DataObjectSet.
  * @param SQLQuery $query The query used to generate this DataObjectSet
  */
 public function parseQueryLimit(SQLQuery $query)
 {
     if ($query->limit) {
         if (is_array($query->limit)) {
             $length = $query->limit['limit'];
             $start = $query->limit['start'];
         } else {
             if (stripos($query->limit, 'OFFSET')) {
                 list($length, $start) = preg_split("/ +OFFSET +/i", trim($query->limit));
             } else {
                 $result = preg_split("/ *, */", trim($query->limit));
                 $start = $result[0];
                 $length = isset($result[1]) ? $result[1] : null;
             }
         }
         if (!$length) {
             $length = $start;
             $start = 0;
         }
         $this->setPageLimits($start, $length, $query->unlimitedRowCount());
     }
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:26,代码来源:DataObjectSet.php

示例3: queryList

 /**
  * Perform a search against the data table.
  *
  * @param array $where Array of strings to add into the WHERE clause
  * @param array $orderby Array of column as key, to direction as value to add into the ORDER BY clause
  * @param string|int $start Record to start at (for paging)
  * @param string|int $pageLength Number of results per page (for paging)
  * @param boolean $paged Paged results or not?
  * @return ArrayList|PaginatedList
  */
 protected function queryList($where = array(), $orderby = array(), $start, $pageLength, $paged = true)
 {
     $dataClass = $this->dataRecord->getDataClass();
     if (!$dataClass) {
         return new PaginatedList(new ArrayList());
     }
     $resultColumns = $this->dataRecord->getDataSingleton()->summaryFields();
     $resultColumns['ID'] = 'ID';
     $results = new ArrayList();
     $query = new SQLQuery();
     $query->setSelect($this->escapeSelect(array_keys($resultColumns)))->setFrom("\"{$dataClass}\"");
     $query->addWhere($where);
     $query->addOrderBy($orderby);
     $query->setConnective('AND');
     if ($paged) {
         $query->setLimit($pageLength, $start);
     }
     foreach ($query->execute() as $record) {
         $result = new $dataClass($record);
         $result->Columns = $this->Columns($result);
         // we attach Columns here so the template can loop through them on each result
         $results->push($result);
     }
     if ($paged) {
         $list = new PaginatedList($results);
         $list->setPageStart($start);
         $list->setPageLength($pageLength);
         $list->setTotalItems($query->unlimitedRowCount());
         $list->setLimitItems(false);
     } else {
         $list = $results;
     }
     return $list;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-registry,代码行数:44,代码来源:RegistryPage.php

示例4: 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 SQLQuery $query
  */
 public function setPaginationFromQuery(SQLQuery $query)
 {
     if ($limit = $query->getLimit()) {
         $this->setPageLength($limit['limit']);
         $this->setPageStart($limit['start']);
         $this->setTotalItems($query->unlimitedRowCount());
     }
     return $this;
 }
开发者ID:miamollie,项目名称:echoAerial,代码行数:15,代码来源:PaginatedList.php

示例5: testParseQueryLimit

 /**
  * Test {@link DataObjectSet->parseQueryLimit()}
  */
 function testParseQueryLimit()
 {
     // Create empty objects, because they don't need to have contents
     $sql = new SQLQuery('*', '"Member"');
     $max = $sql->unlimitedRowCount();
     $set = new DataObjectSet();
     // Test handling an array
     $set->parseQueryLimit($sql->limit(array('limit' => 5, 'start' => 2)));
     $expected = array('pageStart' => 2, 'pageLength' => 5, 'totalSize' => $max);
     $this->assertEquals($expected, $set->getPageLimits(), 'The page limits match expected values.');
     // Test handling OFFSET string
     // uppercase
     $set->parseQueryLimit($sql->limit('3 OFFSET   1'));
     $expected = array('pageStart' => 1, 'pageLength' => 3, 'totalSize' => $max);
     $this->assertEquals($expected, $set->getPageLimits(), 'The page limits match expected values.');
     // and lowercase
     $set->parseQueryLimit($sql->limit('32   offset   3'));
     $expected = array('pageStart' => 3, 'pageLength' => 32, 'totalSize' => $max);
     $this->assertEquals($expected, $set->getPageLimits(), 'The page limits match expected values.');
     // Finally check MySQL LIMIT syntax
     $set->parseQueryLimit($sql->limit('7, 7'));
     $expected = array('pageStart' => 7, 'pageLength' => 7, 'totalSize' => $max);
     $this->assertEquals($expected, $set->getPageLimits(), 'The page limits match expected values.');
 }
开发者ID:hamishcampbell,项目名称:silverstripe-sapphire,代码行数:27,代码来源:DataObjectSetTest.php


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