AbstractQueryBuilder::limit

Add LIMIT,OFFSET Sql statement into Query Builder.

@param    int $limit  LIMIT value
@param    int $offset OFFSET value

@return    static
976830
public function limit($limit, $offset = 0)
    {
        $this->builderCache->store('limit', $limit);
        $this->offset($offset);

        return $this;
    }
743935
public function limit($offset, $limit)
	{
		$this->data = $this->data_source->limit($limit, $offset)->fetchAll();

		return $this;
	}
410392
public function withOffsetLimit($offset, $limit)
    {
        $new = clone $this;
        $new->offset = $offset;
        $new->limit = $limit;
        $new->paginationType = self::OFFSET_LIMIT_PAGINATION;

        return $new;
    }
128042
public function limit($total, $offset = 0)
    {
        $this->_limit = $total;
        $this->_offset = $offset;
        return $this;
    }
106967
public function limit($limit = 0, $offset = 0)
    {
        if (!$limit) {
            return $this;
        }
        if ($offset) {
            $limit .= " OFFSET {$offset}";
        }
        $this->_parts['limit'] = $limit;
        return $this;
    }
822561
public function get($limit = 0, $offset = 0)
    {

        //check if there is an error
        if (static::$response['status'] == "error") {
           return static::terminate(static::$response);
        }

        //check if the limit is a number
        if (!is_numeric($limit)) {
            static::$response["status"] = "error";
            static::$response["response"] = "Parameter limit should be numeric at function get()";
            static::$response["code"] = 6000;

            return static::terminate(static::$response);
        }

        //check if the offset is a number
        if (!is_numeric($offset)) {
            static::$response["status"] = "error";
            static::$response["response"] = "Parameter offset should be numeric at function get()";
            static::$response["code"] = 6001;

            return static::terminate(static::$response);
        }

        $table_name = self::$table;

        /* if no column passed as param, select all	 */
        $columns = empty($this->columns) ? "*" : $this->columns;

        $query = /** @lang text */
            "SELECT {$columns} FROM {$table_name}";

        if (!empty($this->whereby)) {

            $query = $query . ' WHERE ' . $this->whereby;
        }
        if(!empty($this->groupby)){
            $query.=' GROUP BY '.$this->groupby;
        }

        if (!empty($this->order)) {
            $query .= $this->order;
        }


        if (!empty($limit)) {
            $query = $query . ' LIMIT ' . $limit;
        }
        if (!empty($offset)) {
            $query = $query . ' OFFSET ' . $offset;
        }



          return  $this->fetch($query);
    }
425998
public function limit($limit, $offset = null) {
		$this->_criteria->limit($limit, $offset);
		$this->_limit = (int) $limit;
				
		return $this;
	}
1353343
public function applyLimit(&$sql, $offset, $limit)
    {
        $offset = (int) $offset;
        $limit = (int) $limit;

        if ($limit >= 0) {
            $sql .= ' LIMIT ' . ($offset > 0 ? $offset . ', ' : '') . $limit;
        } elseif ($offset > 0) {
            $sql .= ' LIMIT ' . $offset . ', 18446744073709551615';
        }
    }
1287118
public function limit($limit, $offset = null)
    {
        if ($offset) {
            $this->getLimit()->setParams(array($limit, $offset));
        } else {
            $this->getLimit()->setParams(array($limit));
        }

        return $this;
    }
1359917
public function limit($limit)
    {
        if ($this->queryType !== self::QUERY_SELECT) {
            $this->exception = new QueryException("Limit can only be applied on SELECT mode!", 0, $this->exception);
            return $this;
        }
        if (! is_int($limit) || $limit < 0) {
            $this->exception = new QueryException("Limit value should be an positive integer!", 0, $this->exception);
            return $this;
        }
        $this->limitCount = intval($limit);

        return $this;
    }
1254196
public function limit( $limit )
    {
        $limit = (int)$limit;
        if( $limit > 0 )
            $this->limit = $limit;

        return $this;
    }
550873
public function load(int $offset = 0, int $limit = 25): self
    {
        $this->data = array_map(
            function (Location $location) {
                return $this->valueFactory->createBookmark($location);
            },
            $this->bookmarkService->loadBookmarks($offset, $limit)->items
        );

        return $this;
    }
1284811
public function prepareLimit($limit, $offset = null)
    {
        if ($offset) {
            $this->setLimit = ' LIMIT ' . $limit . ', ' . $offset . '';
        } else {
            $this->setLimit = ' LIMIT ' . $limit . '';
        }

        return $this;
    }
180884
public function limit($limit)
    {
        if(!empty($limit))
            $this->selectParams[self::LIMIT] = $limit;
        else
            unset($this->selectParams[self::LIMIT]);
        return $this;
    }
899541
protected function set_limit($query, $limit = 0, $offset = 0)
    {
        $limit  = intval($limit);
        $offset = intval($offset);
        $end    = $offset + $limit;

        // query without OFFSET
        if (!$offset) {
            $query = preg_replace('/^SELECT\s/i', "SELECT TOP $limit ", $query);
            return $query;
        }

        $orderby = stristr($query, 'ORDER BY');
        $offset += 1;

        if ($orderby !== false) {
            $query = trim(substr($query, 0, -1 * strlen($orderby)));
        }
        else {
            // it shouldn't happen, paging without sorting has not much sense
            // @FIXME: I don't know how to build paging query without ORDER BY
            $orderby = "ORDER BY 1";
        }

        $query = preg_replace('/^SELECT\s/i', '', $query);
        $query = "WITH paging AS (SELECT ROW_NUMBER() OVER ($orderby) AS [RowNumber], $query)"
            . " SELECT * FROM paging WHERE [RowNumber] BETWEEN $offset AND $end ORDER BY [RowNumber]";

        return $query;
    }
1107907
protected function queryLimitOffset($query, $limit = null, $offset = 0)
    {
        $limit  = $limit ?: $this->limit;
        $offset = $offset ?: $this->offset;

        if ($limit) {
            $query->take($limit)->skip($offset);
        }

        return $query;
    }
300041
public function limit($count, $offset = 0)
    {
        $this->limit = array((int) $count, (int) $offset);

        return $this;
    }