PageFinder::getQueryStartLimit PHP Method

getQueryStartLimit() protected method

protected getQueryStartLimit ( DatabaseQuerySelect $query, $selectors )
$query DatabaseQuerySelect
    protected function getQueryStartLimit(DatabaseQuerySelect $query, $selectors)
    {
        $start = null;
        $limit = null;
        $sql = '';
        foreach ($selectors as $selector) {
            if ($selector->field == 'start') {
                $start = (int) $selector->value;
            } else {
                if ($selector->field == 'limit') {
                    $limit = (int) $selector->value;
                }
            }
        }
        if ($limit) {
            $this->limit = $limit;
            if (is_null($start) && ($input = $this->wire('input'))) {
                // if not specified in the selector, assume the 'start' property from the default page's pageNum
                $pageNum = $input->pageNum - 1;
                // make it zero based for calculation
                $start = $pageNum * $limit;
            }
            if (!is_null($start)) {
                $sql .= "{$start},";
                $this->start = $start;
            }
            $sql .= "{$limit}";
            if ($this->getTotal && $this->getTotalType != 'count') {
                $query->select("SQL_CALC_FOUND_ROWS");
            }
        }
        if ($sql) {
            $query->limit($sql);
        }
    }