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


PHP QueryBuilder::setFirstResult方法代码示例

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


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

示例1: run

 /**
  * @param QueryBuilder $queryBuilder
  * @param $callback
  * @param int|null $limit
  * @param int $maxAttempts
  * @throws DBALWalkerException
  * @throws DBALException
  */
 public function run(QueryBuilder $queryBuilder, $callback, $limit = null, $maxAttempts = 10)
 {
     if (!is_callable($callback)) {
         throw new DBALWalkerException('$callback is not callable');
     }
     if (!is_null($limit)) {
         $queryBuilder->setMaxResults($limit);
     } else {
         $limit = $queryBuilder->getMaxResults();
     }
     if (is_null($limit)) {
         $limit = PHP_INT_MAX;
     }
     $offset = 0;
     do {
         $rows = [];
         $errors = $maxAttempts;
         while (true) {
             try {
                 $rows = $queryBuilder->setFirstResult($offset)->execute()->fetchAll();
                 break;
             } catch (DBALException $e) {
                 if ($errors-- == 0) {
                     throw $e;
                 }
                 $queryBuilder->getConnection()->connect();
             }
         }
         call_user_func($callback, $rows, $offset, $limit);
         $offset += $limit;
     } while (count($rows) >= $limit);
 }
开发者ID:octava,项目名称:replication,代码行数:40,代码来源:Walker.php

示例2: incorporateDbalQueryBuilder

 /**
  * @internal
  */
 private function incorporateDbalQueryBuilder(QueryBuilder $qb, FilterInterface $filter)
 {
     $criteria = $this->getFilteringCriteria($filter);
     // extraindo os rootAliases, pois o DBAL\QueryBuilder não tem
     $fromPart = $qb->getQueryPart('from');
     $rootAliases = array();
     foreach ($fromPart as $part) {
         $rootAliases[] = $part['alias'];
     }
     $visitor = new DbalQueryExpressionVisitor($qb->getConnection(), $rootAliases, $this->fieldMap);
     if ($whereExpression = $criteria->getWhereExpression()) {
         $qb->andWhere($visitor->dispatch($whereExpression));
         $qb->setParameters($visitor->getParameters());
     }
     if ($criteria->getOrderings()) {
         foreach ($criteria->getOrderings() as $sort => $order) {
             $qb->addOrderBy($visitor->getFieldName($sort), $order);
         }
     }
     if (($firstResult = $criteria->getFirstResult()) !== null) {
         $qb->setFirstResult($firstResult);
     }
     if (($maxResults = $criteria->getMaxResults()) !== null) {
         $qb->setMaxResults($maxResults);
     }
 }
开发者ID:brodaproject,项目名称:broda,代码行数:29,代码来源:DbalQueryBuilderIncorporator.php

示例3: match

 /**
  * @see \ComPHPPuebla\Doctrine\Query\Specification::match()
  */
 public function match(QueryBuilder $qb)
 {
     if ($this->has('page')) {
         $this->page = $this->get('page');
         $this->initPageSize();
         $qb->setFirstResult($this->calculateOffset())->setMaxResults($this->pageSize);
     }
 }
开发者ID:comphppuebla,项目名称:restful-extensions,代码行数:11,代码来源:PaginationSpecification.php

示例4: setDBALQuery

 /**
  * Prepare listing instance from Doctrine DBAL QueryBuilder.
  * 
  * Total rows count for Listing instance must be set separately.
  * 
  * @param DBALQueryBuilder
  * @param boolean
  * @param boolean
  * @return self
  */
 public function setDBALQuery(DBALQueryBuilder $query, $appendLimit = true, $appendOrder = true)
 {
     if ($appendLimit) {
         $query->setFirstResult($this->offset())->setMaxResults($this->limit());
     }
     if ($appendOrder && $this->order()) {
         call_user_func_array([$query, 'orderBy'], (array) $this->order());
     }
     $this->setItems($query->execute()->fetchAll());
     return $this;
 }
开发者ID:minchal,项目名称:vero,代码行数:21,代码来源:DoctrineListing.php

示例5: rewind

 /**
  * Rewind
  */
 public function rewind()
 {
     //Only perform rewind if current item is not the first element
     if ($this->currentKey !== 0) {
         $this->batchPosition = 0;
         $this->queryBuilder->setFirstResult(0);
         $this->queryBuilder->setMaxResults($this->batchSize);
         /* @var $stmt \Doctrine\DBAL\Statement */
         $stmt = $this->queryBuilder->execute();
         $stmt->setFetchMode(\PDO::FETCH_ASSOC);
         $this->currentItem = null;
         $this->currentKey = -1;
         $this->statement = $stmt;
         $this->next();
     }
 }
开发者ID:prooph,项目名称:event-store-doctrine-adapter,代码行数:19,代码来源:DoctrineStreamIterator.php

示例6: getDataQuery

 /**
  * Build the data query
  *
  * @return QueryBuilder
  */
 public function getDataQuery()
 {
     $this->buildFilteredQuery();
     if ($this->offset !== null) {
         $this->currentQueryBuilder->setFirstResult($this->offset);
     }
     if ($this->length !== null) {
         $this->currentQueryBuilder->setMaxResults($this->length);
     }
     if ($this->orders !== null) {
         foreach ($this->orders as $order) {
             list($column, $dir) = $order;
             $this->currentQueryBuilder->addOrderBy($column->sourceSort, $dir);
         }
     }
     if (isset($this->conf->group)) {
         $this->currentQueryBuilder->groupBy($this->conf->group);
     }
     return $this->currentQueryBuilder;
 }
开发者ID:solire,项目名称:trieur,代码行数:25,代码来源:Doctrine.php

示例7: offset

 /**
  * @param int $offset
  * @return $this
  */
 public function offset($offset)
 {
     $this->queryBuilder->setFirstResult($offset);
     return $this;
 }
开发者ID:marcojetson,项目名称:freckle,代码行数:9,代码来源:Query.php

示例8: skip

 public function skip($rows_count)
 {
     parent::setFirstResult($rows_count);
     return $this;
 }
开发者ID:arduanov,项目名称:pimple-active-record,代码行数:5,代码来源:QueryBuilder.php

示例9: next

 public function next()
 {
     $this->offset += $this->maxresults;
     $this->qb->setFirstResult($this->offset);
 }
开发者ID:stopsopa,项目名称:elastic,代码行数:5,代码来源:AbstractDbalProvider.php

示例10: setFirstResult

 /**
  * Sets the position of the first result to retrieve (the "offset").
  *
  * @param integer $firstResult The first result to return.
  *
  * @return self
  */
 public function setFirstResult($firstResult)
 {
     $this->qb->setFirstResult($firstResult);
     return $this;
 }
开发者ID:Maksold,项目名称:platform,代码行数:12,代码来源:SqlQueryBuilder.php

示例11: gridFiltersExt

 function gridFiltersExt(\Doctrine\DBAL\Query\QueryBuilder &$dbalQuery, $params, $aColumnMapping)
 {
     if (is_array($aColumnMapping) && count($aColumnMapping) > 0) {
         foreach ($aColumnMapping as $value) {
             if ($value["ref"] == $params['sSortBy']) {
                 if (!$value["table"]) {
                     $params['sSortBy'] = $value["col"];
                 } else {
                     $params['sSortBy'] = $value["table"] . "." . $value["col"];
                 }
                 break;
             }
         }
     }
     if (is_array($params['aFilters'])) {
         foreach ($params['aFilters'] as $oFilter) {
             $sFieldname = $oFilter->field;
             if (is_array($aColumnMapping) && count($aColumnMapping) > 0) {
                 foreach ($aColumnMapping as $value) {
                     if ($value["ref"] == $sFieldname) {
                         /**
                          * Update Catalin:
                          * Exista situatii cand nu am nevoie de tabel.coloana ex cand folosesc functii gen GROUP_CONCAT
                          */
                         if (!$value["table"]) {
                             $sFieldname = $value["col"];
                         } else {
                             $sFieldname = $value["table"] . "." . $value["col"];
                         }
                         break;
                     }
                 }
             }
             $sValue = $oFilter->value;
             $sCompare = isset($oFilter->comparison) ? $oFilter->comparison : NULL;
             $sFilterType = $oFilter->type;
             switch ($sFilterType) {
                 case 'string':
                     $dbalQuery->andWhere($sFieldname . " like '%{$sValue}%'");
                     break;
                 case 'list':
                     if (strstr($sValue, ',')) {
                         $aValues = explode(',', $sValue);
                         $this->db->andWhere_in($sFieldname, $aValues);
                     } else {
                         $this->db->andWhere($sFieldname, $sValue);
                     }
                     break;
                 case 'boolean':
                     $this->db->andWhere($sFieldname, $sValue);
                     break;
                 case 'combo':
                     $this->db->andWhere($sFieldname, $sValue);
                     break;
                 case 'numeric':
                     switch ($sCompare) {
                         case 'eq':
                             $dbalQuery->andWhere($sFieldname . '=' . $sValue);
                             break;
                         case 'lt':
                             $dbalQuery->andWhere($sFieldname . '<' . $sValue);
                             break;
                         case 'gt':
                             $dbalQuery->andWhere($sFieldname . '>' . $sValue);
                             break;
                         case 'gte':
                             $dbalQuery->andWhere($sFieldname . '>=' . $sValue);
                             break;
                         case 'lte':
                             $dbalQuery->andWhere($sFieldname . '<=' . $sValue);
                             break;
                     }
                     break;
                 case 'date':
                     switch ($sCompare) {
                         case 'eq':
                             $dbalQuery->andWhere("DATE_FORMAT({$sFieldname}, '%Y-%m-%d')='" . date('Y-m-d', strtotime($sValue)) . "'");
                             break;
                         case 'lt':
                             $dbalQuery->andWhere("DATE_FORMAT({$sFieldname}, '%Y-%m-%d')<='" . date('Y-m-d', strtotime($sValue)) . "'");
                             break;
                         case 'gt':
                             $dbalQuery->andWhere("DATE_FORMAT({$sFieldname}, '%Y-%m-%d')>='" . date('Y-m-d', strtotime($sValue)) . "'");
                             break;
                     }
                     break;
             }
         }
     }
     if (!$params['bIsExport']) {
         $dbalQuery->orderBy($params['sSortBy'], $params['sDir']);
         $dbalQuery->setFirstResult($params['sStart']);
         $dbalQuery->setMaxResults($params['sLimit']);
     } else {
         //Limita maxima de inregistrari
         $dbalQuery->setMaxResults(50000);
     }
 }
开发者ID:bardascat,项目名称:blogify,代码行数:98,代码来源:AbstractModel.php

示例12: addPagination

 /**
  * Adds pagination parameters to the query.
  *
  * @param QueryBuilder $queryBuilder
  * the query
  * @param $skip
  * the rows to skip
  * @param $amount
  * the maximum amount of rows
  */
 protected function addPagination(QueryBuilder $queryBuilder, $skip, $amount)
 {
     $queryBuilder->setMaxResults(9999999999);
     if ($amount !== null) {
         $queryBuilder->setMaxResults(abs(intval($amount)));
     }
     if ($skip !== null) {
         $queryBuilder->setFirstResult(abs(intval($skip)));
     }
 }
开发者ID:timfreiheit,项目名称:CRUDlex,代码行数:20,代码来源:CRUDMySQLData.php

示例13: buildLimit

 /**
  * Build up dynamilcy the LIMIT part
  * @param QueryBuilder $qb
  * @param array $limit
  * @return self
  */
 protected function buildLimit(QueryBuilder $qb, array $limit = [])
 {
     switch (count($limit)) {
         case 2:
             $qb->setFirstResult((int) $limit[0]);
             $qb->setMaxResults((int) $limit[1]);
             break;
         case 1:
             $qb->setMaxResults((int) $limit[0]);
             break;
     }
     return $this;
 }
开发者ID:schwaen,项目名称:doctrine-dbal-extensions,代码行数:19,代码来源:Model.php

示例14: testSetFirstResult

 public function testSetFirstResult()
 {
     $qb = new QueryBuilder($this->conn);
     $qb->setFirstResult(10);
     $this->assertEquals(QueryBuilder::STATE_DIRTY, $qb->getState());
     $this->assertEQuals(10, $qb->getFirstResult());
 }
开发者ID:robertowest,项目名称:CuteFlow-V4,代码行数:7,代码来源:QueryBuilderTest.php

示例15: setFirstResultDelegatesToConcreteQueryBuilder

 /**
  * @test
  */
 public function setFirstResultDelegatesToConcreteQueryBuilder()
 {
     $this->concreteQueryBuilder->setFirstResult(Argument::cetera())->shouldBeCalled()->willReturn($this->subject);
     $this->subject->setFirstResult(1);
 }
开发者ID:dachcom-digital,项目名称:TYPO3.CMS,代码行数:8,代码来源:QueryBuilderTest.php


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