Add a limit to the select query.

@param int $pNb
@return SelectAbstract
775588
public function limit($pNb)
    {
        if (is_array($pNb) and count($pNb) == 2 and isset($pNb[0])
            and isset($pNb[1]) and is_int($pNb[0]) and is_int($pNb[1])) {
            $nb = $pNb[1];
            $this->skip($pNb[0]);
        } else if (is_int($pNb)) {
            $nb = $pNb;
        } else {
            throw new Exception("Validation failed for type 'array' or 'int'");
        }

        $this->_limit = $nb;
        return $this;
    }
1084243
public function limit($limit)
    {
        if (null !== $limit) {
            if (!is_numeric($limit) || $limit != (int) $limit) {
                throw new \InvalidArgumentException('The limit is not valid.');
            }
            $limit = (int) $limit;
        }

        $this->limit = $limit;

        return $this;
    }
926470
public function limit($limit, $offset = '')
    {
        if (is_null($limit)) {
            throw new \Exception('Empty parameter given to limit clause ');
        }

        if (empty($offset) && !empty($limit)) {
            $this->limitValue = 0;
            $this->offsetValue = intval($limit);
        } else {
            $this->limitValue = intval($limit);
            $this->offsetValue = intval($offset);
        }

        return $this;
    }
219918
public function limit($limit, $offset = null)
    {
        if ($offset !== null) {
            $this->builder->setFirstResult((int) $offset);
        }

        $this->builder->setMaxResults((int) $limit);

        return $this;
    }
827919
public function limit($limit = 0)
	{
		if (is_null($this->limit))
		{
			$this->limit = new QueryElement('LIMIT', (int) $limit);
		}

		return $this;
	}
378458
public function limit($limit)
    {
        $limit = (int)$limit;
        $limit < 1 && $limit = 1;
        return $this->add('limit', $limit);
    }
244037
protected function _limit($sql)
	{
		// Limit clause depends on if Interbase or Firebird
		if (stripos($this->version(), 'firebird') !== FALSE)
		{
			$select = 'FIRST '.$this->qb_limit
				.($this->qb_offset ? ' SKIP '.$this->qb_offset : '');
		}
		else
		{
			$select = 'ROWS '
				.($this->qb_offset ? $this->qb_offset.' TO '.($this->qb_limit + $this->qb_offset) : $this->qb_limit);
		}

		return preg_replace('`SELECT`i', 'SELECT '.$select, $sql, 1);
	}
411143
public function setLimit($limit)
    {
        $this->limit = (int)$limit;

        if ($this->total > 0 && $this->limit > 0) {
            $this->setPages(ceil($this->total / $limit));
        }

        return $this;
    }
739559
public function setLimit($limit)
    {
        if (!isset($this->_persistence) || !($this->_persistence instanceof IPersistance)) {
            throw new Exception("Repository Exception : No existe la interfaz de la persistencia o no implementa la interfaz IPersistance.");
        }

        $this->_persistence->setLimit($limit);

        return $this;
    }
211162
public function limit($limit = null) {
		if (is_null($limit)) //remove options
			return $this->discard('query.limit');
	
		return $this->merge(['query.limit' => intval($limit)]);
	}
281927
function applyLimit(&$sql, $offset, $limit) {

		$max = $offset + $limit;

		// nesting all queries, in case there's already a WHERE clause
		$sql = <<<EOF
SELECT A.*, rownum AS PROPEL\$ROWNUM
FROM (
  $sql
) A
WHERE rownum <= $max
EOF;

		if ($offset > 0) {
			$sql = <<<EOF
SELECT B.*
FROM (
  $sql
) B
WHERE B.PROPEL\$ROWNUM > $offset
EOF;
		}
	}
498601
public function addSelect($_)
    {
        RecursiveArgs::each(func_get_args(), function ($arg) {
           $this->selectClauses[] = $arg;
        });

        return $this;
    }
349516
public function limit(int $limit)
    {
        $this->query = array_merge($this->query ?? [], ['limit' => $limit]);

        return $this;
    }
479812
protected function set_limit($query, $limit = 0, $offset = 0)
    {
        $limit  = intval($limit);
        $offset = intval($offset);
        $end    = $offset + $limit;

        // @TODO: Oracle 12g has better OFFSET support

        if (!$offset) {
            $query = "SELECT * FROM ($query) a WHERE rownum <= $end";
        }
        else {
            $query = "SELECT * FROM (SELECT a.*, rownum as rn FROM ($query) a WHERE rownum <= $end) b WHERE rn > $offset";
        }

        return $query;
    }
1132457
public function addSelect($select)
    {
        if (null === $select) {
            return $this;
        }
        if (is_array($select)) {
            $t = [];
            foreach ($select as $field => $alias) {
                if (is_int($field)) {
                    $alias = $this->quoteColumnName($alias);
                    array_push($t, "{$alias}");
                } else {
                    $field = $this->quoteColumnName($field);
                    $alias = $this->quoteColumnName($alias);
                    array_push($t, "{$field} AS {$alias}");
                }
            }
            $select = implode(',', $t);
        }
        if (isset($this->query['select']) && !empty($this->query['select'])) {
            $select = "{$this->query['select']},{$select}";
        }
        $this->query['select'] = $select;
        return $this;
    }
919078
public function limit(int $limit = 0): Select
    {
        if (!\is_int($limit) || $limit <= 0) {
            throw new InvalidArgumentException('$limit have to be a positive integer');
        }
        $this->limit = $limit;
        return $this;
    }
249499
public function limit($limit, $startFrom = false)
    {
        if ($startFrom !== false) {
            $this->setLimit(' LIMIT ' . $startFrom . ', ' . $limit);
        } else {
            $this->setLimit(' LIMIT ' . $limit);
        }

        return $this;
    }