getMaxResults() public method

Returns NULL if {@link setMaxResults} was not applied to this query builder.
public getMaxResults ( ) : integer
return integer The maximum number of results.
Esempio n. 1
42
 /**
  * @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);
 }
 /**
  * @test
  */
 public function getMaxResultsDelegatesToConcreteQueryBuilder()
 {
     $this->concreteQueryBuilder->getMaxResults()->shouldBeCalled()->willReturn(1);
     $this->subject->getMaxResults();
 }
 public function testSetMaxResults()
 {
     $qb = new QueryBuilder($this->conn);
     $qb->setMaxResults(10);
     $this->assertEquals(QueryBuilder::STATE_DIRTY, $qb->getState());
     $this->assertEQuals(10, $qb->getMaxResults());
 }
Esempio n. 4
0
 /**
  * Gets the maximum number of results the query object was set to retrieve (the "limit").
  * Returns NULL if {@link setMaxResults} was not applied to this query builder.
  *
  * @return integer The maximum number of results.
  */
 public function getMaxResults()
 {
     return $this->queryBuilder->getMaxResults();
 }
Esempio n. 5
0
 /**
  * Gets the maximum number of results the query object was set to retrieve (the "limit").
  * Returns 0 if setMaxResults was not applied to this query builder.
  *
  * @return int The maximum number of results.
  */
 public function getMaxResults() : int
 {
     return (int) $this->concreteQueryBuilder->getMaxResults();
 }
Esempio n. 6
0
 /**
  * Gets the maximum number of results the query object was set to retrieve (the "limit").
  * Returns NULL if {@link setMaxResults} was not applied to this query builder.
  *
  * @return integer The maximum number of results.
  */
 public function getMaxResults()
 {
     return $this->qb->getMaxResults();
 }