public function limit($maxResults, $offset = null)
    {
        if (!is_int($maxResults)) {
            throw new Exception\InvalidArgumentException('Incorrect argument $maxResults. Only number allowed.');
        }

        if ($maxResults < 1) {
            throw new Exception\InvalidArgumentException(
                sprintf('Incorrect maximum results: %d. Only positive number allowed.', $maxResults)
            );
        }

        $this->setMaxResults($maxResults);

        if ($offset !== null) {
            if (!is_int($offset)) {
                throw new Exception\InvalidArgumentException('Incorrect argument $offset. Only number allowed.');
            }

            if ($offset < 0) {
                throw new Exception\InvalidArgumentException(
                    sprintf('Incorrect offset: %d. Only positive number allowed.', $offset)
                );
            }

            $this->setFirstResult($offset);
        }

        return $this;
    }
public function limit($maxResults, $offset = null)
    {
        if (!is_int($maxResults)) {
            throw new Exception\InvalidArgumentException('Incorrect argument $maxResults. Only number allowed.');
        }

        if ($maxResults < 1) {
            throw new Exception\InvalidArgumentException(
                sprintf('Incorrect maximum results: %d. Only positive number allowed.', $maxResults)
            );
        }

        $this->setMaxResults($maxResults);

        if ($offset !== null) {
            if (!is_int($offset)) {
                throw new Exception\InvalidArgumentException('Incorrect argument $offset. Only number allowed.');
            }

            if ($offset < 0) {
                throw new Exception\InvalidArgumentException(
                    sprintf('Incorrect offset: %d. Only positive number allowed.', $offset)
                );
            }

            $this->setFirstResult($offset);
        }

        return $this;
    }
public function limit ( $ maxResults , $ offset = null ) { if ( ! is_int ( $ maxResults ) ) { throw new Exception \ InvalidArgumentException ( 'Incorrect argument $maxResults. Only number allowed.' ) ; } if ( $ maxResults < 1 ) { throw new Exception \ InvalidArgumentException ( sprintf ( 'Incorrect maximum results: %d. Only positive number allowed.' , $ maxResults ) ) ; } $ this -> setMaxResults ( $ maxResults ) ; if ( $ offset !== null ) { if ( ! is_int ( $ offset ) ) { throw new Exception \ InvalidArgumentException ( 'Incorrect argument $offset. Only number allowed.' ) ; } if ( $ offset < 0 ) { throw new Exception \ InvalidArgumentException ( sprintf ( 'Incorrect offset: %d. Only positive number allowed.' , $ offset ) ) ; } $ this -> setFirstResult ( $ offset ) ; } return $ this ; }
Limit max number of results

@param int $maxResults
@param int $offset

@return $this This QueryBuilder instance.
@throws Exception\InvalidArgumentException
Limit max number of results