framework/db/QueryBuilder.php
public function buildOrderByAndLimit($sql, $orderBy, $limit, $offset)
    {
        $orderBy = $this->buildOrderBy($orderBy);
        if ($orderBy !== '') {
            $sql .= $this->separator . $orderBy;
        }
        $limit = $this->buildLimit($limit, $offset);
        if ($limit !== '') {
            $sql .= $this->separator . $limit;
        }

        return $sql;
    }
public function buildOrderByAndLimit($sql, $orderBy, $limit, $offset)
    {
        $orderBy = $this->buildOrderBy($orderBy);
        if ($orderBy !== '') {
            $sql .= $this->separator . $orderBy;
        }
        $limit = $this->buildLimit($limit, $offset);
        if ($limit !== '') {
            $sql .= $this->separator . $limit;
        }

        return $sql;
    }
Builds the ORDER BY and LIMIT/OFFSET clauses and appends them to the given SQL.
@param string $sql the existing SQL (without ORDER BY/LIMIT/OFFSET)
@param array $orderBy the order by columns. See [[Query::orderBy]] for more details on how to specify this parameter.
@param int $limit the limit number. See [[Query::limit]] for more details.
@param int $offset the offset number. See [[Query::offset]] for more details.
@return string the SQL completed with ORDER BY/LIMIT/OFFSET (if any)