src/ORM/Queries/SQLSelect.php
public function setLimit($limit, $offset = 0)
    {
        if ((is_numeric($limit) && $limit < 0) || (is_numeric($offset) && $offset < 0)) {
            throw new InvalidArgumentException("SQLSelect::setLimit() only takes positive values");
        }

        if ($limit === 0) {
            Deprecation::notice(
                '4.3',
                "setLimit(0) is deprecated in SS4. To clear limit, call setLimit(null). " .
                    "In SS5 a limit of 0 will instead return no records."
            );
        }

        if (is_numeric($limit) && ($limit || $offset)) {
            $this->limit = array(
                'start' => (int)$offset,
                'limit' => (int)$limit,
            );
        } elseif ($limit && is_string($limit)) {
            if (strpos($limit, ',') !== false) {
                list($start, $innerLimit) = explode(',', $limit, 2);
            } else {
                list($innerLimit, $start) = explode(' OFFSET ', strtoupper($limit), 2);
            }

            $this->limit = array(
                'start' => (int)$start,
                'limit' => (int)$innerLimit,
            );
        } elseif ($limit === null && $offset) {
            $this->limit = array(
                'start' => (int)$offset,
                'limit' => $limit
            );
        } else {
            $this->limit = $limit;
        }

        return $this;
    }
public function setLimit($limit, $offset = 0)
    {
        if ((is_numeric($limit) && $limit < 0) || (is_numeric($offset) && $offset < 0)) {
            throw new InvalidArgumentException("SQLSelect::setLimit() only takes positive values");
        }

        if ($limit === 0) {
            Deprecation::notice(
                '4.3',
                "setLimit(0) is deprecated in SS4. To clear limit, call setLimit(null). " .
                    "In SS5 a limit of 0 will instead return no records."
            );
        }

        if (is_numeric($limit) && ($limit || $offset)) {
            $this->limit = array(
                'start' => (int)$offset,
                'limit' => (int)$limit,
            );
        } elseif ($limit && is_string($limit)) {
            if (strpos($limit, ',') !== false) {
                list($start, $innerLimit) = explode(',', $limit, 2);
            } else {
                list($innerLimit, $start) = explode(' OFFSET ', strtoupper($limit), 2);
            }

            $this->limit = array(
                'start' => (int)$start,
                'limit' => (int)$innerLimit,
            );
        } elseif ($limit === null && $offset) {
            $this->limit = array(
                'start' => (int)$offset,
                'limit' => $limit
            );
        } else {
            $this->limit = $limit;
        }

        return $this;
    }
public function setLimit ( $ limit , $ offset = 0 ) { if ( ( is_numeric ( $ limit ) && $ limit < 0 ) || ( is_numeric ( $ offset ) && $ offset < 0 ) ) { throw new InvalidArgumentException ( "SQLSelect::setLimit() only takes positive values" ) ; } if ( $ limit === 0 ) { Deprecation :: notice ( '4.3' , "setLimit(0) is deprecated in SS4. To clear limit, call setLimit(null). " . "In SS5 a limit of 0 will instead return no records." ) ; } if ( is_numeric ( $ limit ) && ( $ limit || $ offset ) ) { $ this -> limit = array ( 'start' => ( int ) $ offset , 'limit' => ( int ) $ limit , ) ; } elseif ( $ limit && is_string ( $ limit ) ) { if ( strpos ( $ limit , ',' ) !== false ) { list ( $ start , $ innerLimit ) = explode ( ',' , $ limit , 2 ) ; } else { list ( $ innerLimit , $ start ) = explode ( ' OFFSET ' , strtoupper ( $ limit ) , 2 ) ; } $ this -> limit = array ( 'start' => ( int ) $ start , 'limit' => ( int ) $ innerLimit , ) ; } elseif ( $ limit === null && $ offset ) { $ this -> limit = array ( 'start' => ( int ) $ offset , 'limit' => $ limit ) ; } else { $ this -> limit = $ limit ; } return $ this ; }
Pass LIMIT clause either as SQL snippet or in array format.
Internally, limit will always be stored as a map containing the keys 'start' and 'limit'

@param int|string|array|null $limit If passed as a string or array, assumes SQL escaped data.
Only applies for positive values.
@param int $offset
@throws InvalidArgumentException
@return $this Self reference
Pass LIMIT clause either as SQL snippet or in array format . Internally limit will always be stored as a map containing the keys start and limit