Prepare HTTP query string.

@param  string  $query
@param  array   $appends

@return string
185958
protected function prepareHttpQueryString(string $query, array $appends = []): string
    {
        if (! empty($appends)) {
            $query .= (! empty($query) ? '&' : '').http_build_query($appends);
        }

        return $query;
    }
636175
public function scopeRequestAppend($query, Request $request)
    {
        if ($request->has('append')) {
            $query->append($request->input('append'));
        }

        return $query;
    }
165834
public function prepareQuery($query, $params = false)
    {
        if (isset($params) and is_array($params)) {
            $this->prepareParms($params);
        }

        if (!isset($this->setQuery)) {
            $this->setQuery = $query . ' ';
        } else {
            $this->setQuery .= $this->getQuery() . ' ' . $query . ' ';
        }

        return $this;
    }
964349
protected function prepareQueryForLog(string $query, array $params): string
	{
		return preg_replace_callback('/\?/', function() use (&$params)
		{
			$param = array_shift($params);

			if(is_int($param) || is_float($param))
			{
				return $param;
			}
			elseif(is_bool(($param)))
			{
				return $param ? 'TRUE' : 'FALSE';
			}
			elseif(is_object($param))
			{
				return get_class($param);
			}
			elseif(is_null($param))
			{
				return 'NULL';
			}
			elseif(is_resource($param))
			{
				return 'resource';
			}
			else
			{
				return $this->pdo->quote($param);
			}
		}, $query);
	}
71750
public static function Format(string $query, ...$vars)
        {
            return preg_replace_callback(
                "~(%%?)(\d+)~i",
                function ($match) use (&$vars) {
                    $idx = $match[2] - 1;
                    if (!isset($vars[$idx])) {
                        return $match[0];
                    }

                    $val = &$vars[$match[2] - 1];

                    if ($match[1] === '%%') {
                        return "'{$val}'";
                    }
                    else if (is_null($val)) {
                        return "NULL";
                    }
                    else if (is_bool($val)) {
                        return $val ? 'true' : 'false';
                    }

                    return "'" . pg_escape_string($vars[$idx]) . "'";
                },
                $query
            );
        }
884064
protected function prepareParams($query, $sqlParams)
    {
        if (empty($sqlParams)) {
            $sqlParams = [];
        }
        uksort(
            $sqlParams,
            function ($k1, $k2) {
                return strlen($k1) < strlen($k2);
            }
        );
        $resultQuery = $query;
        $paramNum = 0;
        foreach ($sqlParams as $paName => $paValue) {
            if (gettype($paValue)==="array") {
                $paramList = [];
                foreach ($paValue as $i=>$value) {
                    // $paramList[] = $paName . "_param$i";
                    $paramList[] = ":pdoParam$paramNum";
                    $paramNum++;
                }
                $resultQuery = str_replace($paName, implode(",", $paramList), $resultQuery);
            }
        }
        return $resultQuery;
    }
849566
private function prepareQueryFiler($query)
    {
        $result = [];
        foreach ($query as $key => $value) {
            if (is_array($value)) {
                $result[$key] = $this->prepareQueryFiler($value);
            } elseif (is_string($value) && preg_match('#^(MongoDB\\\\BSON\\\\[A-Za-z]+)\\((.*)\\)$#s', $value, $matches)) {
                $class = $matches[1];
                $objectValue = $matches[1];

                try {
                    $result[$key] = new $class($objectValue);
                } catch (\Exception $e) {
                    $result[$key] = $value;
                }
            } else {
                $result[$key] = $value;
            }
        }
        return $result;
    }
688718
public void append(final Filter query) {
        switch (this.queryType) {
            case OR: {
                this.orFilter.or(query);
            }
            break;

            default:
            case AND: {
                this.andFilter.and(query);
            }
            break;
        }
    }
548897
public function prepare($query, array $bindings=[])
    {
        $statement = $this->statement($query);

        $this->callBeforeListeners('prepare',[$query, $bindings]);

        $prepared = (new PDOPrepared(
            $statement,
            $query,
            $this->getOption(self::RETURN_LAST_AFFECTED),
            $this->errorHandler
        ))->bind($bindings);

        $this->callAfterListeners('prepare',[$query, $bindings, $prepared]);

        return $prepared;

    }
1105015
function appendQueryParameters(url, parameters){
    
    var hash = "", indexOf = url.indexOf("#");
    if (indexOf !== -1) {
        hash = url.substring(indexOf);
        url = url.substring(0, indexOf);
    }
    var q = [];
    for (var key in parameters) {
        if (parameters.hasOwnProperty(key)) {
            q.push(key + "=" + encodeURIComponent(parameters[key]));
        }
    }
    return url + (useHash ? "#" : (url.indexOf("?") == -1 ? "?" : "&")) + q.join("&") + hash;
}
598349
protected function formatQueryString($params = array())
    {
        $qString = array();
        foreach ($params as $name => $value) {
            if (is_array($value)) {
                foreach ($value as $val) {
                    $val = $this->isUtf8($val) ? $val : utf8_encode($val);
                    $qString[] = $name . '=' . urlencode($val);
                }
            } else {
                $value = $this->isUtf8($value) ? $value : utf8_encode($value);
                $qString[] = $name . '=' . urlencode($value);
            }
        }
        return implode('&', $qString);
    }
1267916
private function prepareStatement($query, $parameters) {
            $stmt = $this->db_connection->prepare($query);

            if (!empty($parameters)) {
                foreach ($parameters as $key => $val) {
                    $stmt->bindValue($key, $val);
                }
            }

            return $stmt;
        }
933068
private function http_build_query($query) {
        $uri = [];
        foreach($query as $k => $v) {
            array_push($uri, $k . '='. $v);
        }

        return implode('&', $uri);
    }
342641
public static function mergeQuery($url, array $query)
    {
        // No query.
        if (!$query) {
            return $url;
        }

        $queryString = http_build_query($query);
        $qPos = strpos($url, '?');
        $hashPos = strpos($url, '#');
        $pos = strlen($url);
        $hasQuery = $qPos !== false && ($qPos < $hashPos || $hashPos === false);

        if ($qPos || $hashPos) {
            $pos = $hasQuery ? $qPos + 1 : $hashPos;
        }

        $prefix = substr($url, 0, $pos);
        $suffix = substr($url, $pos);

        return sprintf(
            '%s%s%s%s%s',
            $prefix,
            $hasQuery ? '' : '?',
            $queryString,
            $hasQuery ? '&' : '',
            $suffix
        );
    }
910912
function appendQuery(path, query) {
  if (query) {
    if (isObject(query)) {
      query = querystring.stringify(query);
    }
    if (isString(query)) {
      let sep = path.indexOf('?') < 0 ? '?' : '&';
      return path + sep + query;
    }
  }
  return path;
}
84962
protected function appendage($appends)
        {
            // The developer may assign an array of values that will be converted to a
            // query string and attached to every pagination link. This allows simple
            // implementation of sorting or other things the developer may need.
            if (!is_null($this->appendage)) {
                return $this->appendage;
            }

            if (count($appends) <= 0) {
                return $this->appendage = '';
            }

            return $this->appendage = '&' . http_build_query($appends);
        }
867364
public function prepare($query, $args = null) {

		if(strlen($query) === 0) return;

		if(!is_array($args)) {
			$args = func_get_args();
			array_shift($args);
		}


		$query = str_replace(array("'?'", '"?"'), '?', $query);
		$query = preg_replace('/\?/', '%s', $query);
		$args = array_map(array($this, 'escape'), $args);

		return @vsprintf($query, $args);

	}