Returns the URL for the execution of a query.

@param string $database
@param string $query
@param int $limit
@param string $fetchPlan
@return string
501525
protected function getQueryLocation($database, $query, $limit = null, $fetchPlan = null, $language = BindingInterface::LANGUAGE_SQLPLUS)
    {
        $arguments = array($language, $query);

        if (isset($limit)) {
            $arguments[] = $limit;
        }

        if (isset($fetchPlan)) {
            $arguments[] = $fetchPlan;
        }

        return $this->getLocation('query', $database, $arguments);
    }
1244409
public function query($query, $params = null, $fetchResult = false)
        {
            $this->checkConnection(true);
            $this->log('Query: ' . $query);

            if(!empty($params)) {
                $this->log('Params: ' . print_r($params, true));
            }
            $start =  microtime(true);

            if(empty($params)) {
                $res = $this->executeQuery($query);
            } else {
                $res = $this->executePreparedStatement($query, $params);
            }

            $end = microtime(true);
            $this->log("Execution time: " . ($end - $start) . " seconds");


            if($fetchResult) {
    	        $this->log('Num Rows: '.odbc_num_rows($res));
                $resutlSet = $this->getRows($res);
                odbc_free_result($res);
                $res = $resutlSet;
                $resultSet = null;
                $fetch = microtime(true);
                $this->log("Fetch time: " . ($fetch - $end) . " seconds");
            }
            return $res;
        }
1120213
public function fetchResults($query, $page = 1, $maxPerPage = 10, $filter = false, $paginate = false)
    {
        if ($paginate) {
            if (!$this->pager) {
                throw new \Exception('Please inject a pager on ResultBuilder');
            }

            $results = $this->pager->paginate($query, $page, $maxPerPage);
        } else {
            $results = $this->queryExecutor->fetch($query, $page, $maxPerPage);
        }

        if ($filter) {
            return $this->filterManager->filter($results);
        }

        return $results;
    }
1343319
private function _mysql_query($query) {

        // call "mysqli_query"
        $result = mysqli_query($this->link, $query);

        // stop if there was an error
        if (!$result) throw new Exception($this->_mysql_error());

        // return the result if query was successful
        return $result;

    }
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;
    }
1321420
public function pagination(int $limit = 20, int $offset = 0, ?callable $totalQuery = null)
    {
        $query = clone $this->selectQueryInstance();

        return $query->paginate($limit, $offset, $totalQuery);
    }
80585
public function search($query, $limit = Pagination::DEFAULT_LIMIT)
    {
        return $this->paginateCustom(function () use ($query) {
            return $this->execSearchRequest($query, $this->getSearchScope());
        })->take($limit);
    }
808585
private function executeQuery(string $url, string $locale = null, int $limit): AddressCollection
    {
        if (null !== $locale) {
            $url = sprintf('%s&lang=%s', $url, str_replace('_', '-', $locale));
        }

        $url = sprintf('%s&results=%d', $url, $limit);
        $content = $this->getUrlContents($url);
        $json = json_decode($content, true);

        if (empty($json) || isset($json['error']) ||
            (isset($json['response']) && '0' === $json['response']['GeoObjectCollection']['metaDataProperty']['GeocoderResponseMetaData']['found'])
        ) {
            return new AddressCollection([]);
        }

        $data = $json['response']['GeoObjectCollection']['featureMember'];

        $locations = [];
        foreach ($data as $item) {
            $builder = new AddressBuilder($this->getName());
            $bounds = null;
            $flatArray = ['pos' => ' '];

            array_walk_recursive(
                $item['GeoObject'],

                /**
                 * @param string $value
                 */
                function ($value, $key) use (&$flatArray) {
                    $flatArray[$key] = $value;
                }
            );

            if (!empty($flatArray['lowerCorner']) && !empty($flatArray['upperCorner'])) {
                $lowerCorner = explode(' ', $flatArray['lowerCorner']);
                $upperCorner = explode(' ', $flatArray['upperCorner']);
                $builder->setBounds(
                    (float) $lowerCorner[1],
                    (float) $lowerCorner[0],
                    (float) $upperCorner[1],
                    (float) $upperCorner[0]
                );
            }

            $coordinates = explode(' ', $flatArray['pos']);
            $builder->setCoordinates((float) $coordinates[1], (float) $coordinates[0]);

            foreach (['AdministrativeAreaName', 'SubAdministrativeAreaName'] as $i => $name) {
                if (isset($flatArray[$name])) {
                    $builder->addAdminLevel($i + 1, $flatArray[$name], null);
                }
            }

            $builder->setStreetNumber(isset($flatArray['PremiseNumber']) ? $flatArray['PremiseNumber'] : null);
            $builder->setStreetName(isset($flatArray['ThoroughfareName']) ? $flatArray['ThoroughfareName'] : null);
            $builder->setSubLocality(isset($flatArray['DependentLocalityName']) ? $flatArray['DependentLocalityName'] : null);
            $builder->setLocality(isset($flatArray['LocalityName']) ? $flatArray['LocalityName'] : null);
            $builder->setCountry(isset($flatArray['CountryName']) ? $flatArray['CountryName'] : null);
            $builder->setCountryCode(isset($flatArray['CountryNameCode']) ? $flatArray['CountryNameCode'] : null);

            /** @var YandexAddress $location */
            $location = $builder->build(YandexAddress::class);
            $location = $location->withPrecision(isset($flatArray['precision']) ? $flatArray['precision'] : null);
            $location = $location->withName(isset($flatArray['name']) ? $flatArray['name'] : null);
            $location = $location->withKind($flatArray['kind'] ?? null);
            $locations[] = $location;
        }

        return new AddressCollection($locations);
    }
1237230
public final function get(string $query, array $queryParams = null, string $fetchClass = null)
    {
        return $this->query($query, $queryParams, 1, $fetchClass)->getData(0);
    }
1117453
protected function getDatabaseDeltasUrl(
        $databaseId = null,
        $context = null,
        $fields = [],
        $baseRevision = null,
        $limit = null
    ) {
        if ($context) {
            $this->setContext($context);
        }
        if ($databaseId) {
            $this->setDatabaseId($databaseId);
        }
        $params = [];
        if ($baseRevision !== null) {
            $params['base_revision'] = $baseRevision;
        }
        if ($limit) {
            $params['limit'] = $limit;
        }
        if ($fields) {
            $params['fields'] = implode(',', $fields);
        }

        return $this->serviceScheme . '://' . $this->serviceDomain . '/' . $this->version . '/data/'
        . $this->getContext() . '/databases/' . $this->getDatabaseId() . '/deltas?' . http_build_query($params);
    }
425891
public function limit(string $sql, int $limit, $offset=FALSE): string
	{
		$sql .= "\nLIMIT {$limit}";

		if (is_numeric($offset))
		{
			$sql .= " OFFSET {$offset}";
		}

		return $sql;
	}
282048
public static function paginate($limit = 10, $sql = '', $binding = [])
    {
        $page = request('page', 1);
        if (!is_numeric($page)) {
            $page = 1;
        }

        $offset = ($page - 1) * $limit;
        $sql .= " limit $limit offset $offset";
        $items = static::findAll($sql, $binding);
        $total = static::countAll($sql, $binding);

        return new Paginator($items, $page, $limit, $total);
    }
66020
protected function _buildLimitPart($limit, $query)
    {
        if (intval($limit) < 1) {
            return '';
        }

        $endRow = intval($query->clause('offset')) + $limit;
        $origEpilog = $query->clause('epilog');
        $offsetEndWrap = '';
        if (is_array($origEpilog) && array_key_exists('snelgOracleOrigEpilog', $origEpilog)) {
            $offsetEndWrap = empty($origEpilog['snelgOracleOffsetEndWrap']) ? '' : $origEpilog['snelgOracleOffsetEndWrap'];
            $origEpilog = $origEpilog['snelgOracleOrigEpilog'];
        }

        //See note in _buildOffsetPart about ->bind being potentially
        //more efficient here
        $query->epilog([
            'snelgOracleOrigEpilog' => $origEpilog,
            'snelgOracleLimitEndWrap' => ") a WHERE ROWNUM <= $endRow",
            'snelgOracleOffsetEndWrap' => $offsetEndWrap
        ]);

        return 'SELECT /*+ FIRST_ROWS(n) */ a.*, ROWNUM snelg_oracle_sub_rnum FROM (';
    }
69542
public function getFromWhere($from, $where=NULL, $where_values=array(), $order=NULL, $limit=NULL, $offset=NULL){
        $res= FALSE;
        try{
            //Armo partes de la consulta
            if($order != NULL){$order= " ORDER BY " . $order;}
            if($limit != NULL){
                $limit= " LIMIT " . $limit;
                if($offset != NULL){$limit.= ' OFFSET ' . $offset;}
            }
            //Armo y preparo la consulta
            $query= $this->prepareSelect($this->select, $from, $where, '', '', $order, $limit);
            //Ejecuto la consulta
            $query->execute($where_values);
            //Controlo que este todo bien
            if($this->isOk($query)){
                $res= $query;
            }
            //Limpio las variables del AR
            $this->cleanVars();
        } catch (\PDOException $e) {
            $this->cleanVars();
            throw $e;
        }
        return $res;
    }
293846
private function build_limit( $limit, $offset ) {
		$sql = '';
		if ( isset( $limit ) && $limit > 0 ) {
			if ( isset( $offset ) && $offset > 0 ) {
				$sql .= " LIMIT {$offset}, {$limit}";
			} else {
				$sql .= " LIMIT {$limit}";
			}
		}

		return $sql;
	}
1129765
public function buildUpdateQuery($table, $data, $where, $limit)
    {
        $sql = "UPDATE " . $this->quoteSpecialName($table) . " SET ";

        $values = '';

        foreach ($data as $key => $value) {
            if (!empty($values)) $values .= ', ';
            $values .= $this->quoteSpecialName($key) . ' = ' . $this->escapeItem($value);
        }

        $sql .= $values . ' WHERE ' . $where;

        if (!empty($limit)) {
            $sql .= ' LIMIT ' . $limit;
        }

        $sql .= ';';

        return $sql;
    }
478501
public function scopeRecentlyEdited(Builder $query, $limit = null)
    {
        $query->orderBy('updated_at', 'desc');

        if ($limit)
        {
            $query->limit($limit);
        }

        return $query;
    }