@param array  $aAddParams              parameters to add to URL
@param string $query                   URL query part
@param bool   $allowParameterOverwrite Decides if same parameters should overwrite query parameters

@return array
196401
private function mergeDuplicatedParameters($aAddParams, $query, $allowParameterOverwrite = true)
    {
        parse_str($query, $currentUrlParameters);
        if ($allowParameterOverwrite) {
            $newParameters = array_merge($currentUrlParameters, $aAddParams);
        } else {
            $newFilteredParameters = array_diff_key($aAddParams, $currentUrlParameters);
            $newParameters = array_merge($currentUrlParameters, $newFilteredParameters);
        }

        return $newParameters;
    }
960912
function getQueryParams(params) {
        params = params || {};
        var url = $location.url();
        var idx = url.indexOf('?');

        // if there is a query string
        if (idx < 0) { return {}; }

        // get the query string and split the keyvals
        var query = url.substring(idx + 1);
        var keyVals = query.split('&');

        // put each key/val into the params object
        _.each(keyVals, function (keyVal) {
            var keyValArr = keyVal.split('=');
            params[keyValArr[0]] = keyValArr[1];
        });

        return params;
    }
889498
public static function buildWheres(QueryInterface $query, array $conditions, $allowNulls = true)
    {
        foreach ($conditions as $key => $value) {
            // NULL
            if ($value === null && $allowNulls) {
                $query->where($query->format('%n IS NULL', $key));
            } elseif ($value instanceof Compare) {
                // If using Compare class, we convert it to string.
                $query->where((string) static::buildCompare($key, $value, $query));
            } elseif (is_numeric($key)) {
                // If key is numeric, just send value to query where.
                $query->where($value);
            } elseif (is_array($value) || is_object($value)) {
                // If is array or object, we use "IN" condition.
                if ($value instanceof \Traversable) {
                    $value = iterator_to_array($value);
                } elseif (is_object($value)) {
                    $value = get_object_vars($value);
                }

                $value = array_map([$query, 'quote'], $value);

                $query->where($query->quoteName($key) . new QueryElement('IN ()', $value, ','));
            } else {
                // Otherwise, we use equal condition.
                $query->where($query->format('%n = %q', $key, $value));
            }
        }

        return $query;
    }
129440
protected function getQueryParameters($query)
    {
        $pairs = explode('&', $query);

        $parameters = [];

        foreach ($pairs as $pair) {
            if ('' === trim($pair)) {
                continue;
            }

            $nameValue = explode('=', $pair);

            $name = urlencode($nameValue[0]);
            $value = urlencode($nameValue[1]);

            $parameters[$name] = $value;
        }

        return $parameters;
    }
661702
private function escapeSql($query, $params = []) {

		if(false === is_string($query)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($query)), E_USER_ERROR);
		}

		if(false === is_array($params)) {
			return trigger_error(sprintf('Argument 2 passed to %s() must be of the type array, "%s" given', __METHOD__, gettype($data)), E_USER_ERROR);
		}

		//Check the type of param binding ("?" = all keys are numeric or ":" = all keys are strings)
	 	if(0 !== count(array_filter(array_keys($params), 'is_string'))) {
			$query = $this -> escapeSemicolon($query, $params);
	 	}

	 	//Variables are bind with the ? sign
	 	else {
	 		$query = $this -> escapeQuestionmark($query, $params);
	 	}

	 	return $query;
	}
588469
public function batchActionCancelled(ProxyQueryInterface $query)
    {
        if (false === $this->admin->isGranted('EDIT')) {
            throw new AccessDeniedException();
        }

        foreach ($query->execute() as $message) {
            $this->getMessageManager()->cancel($message);
        }

        return new RedirectResponse($this->admin->generateUrl('list', $this->admin->getFilterParameters()));
    }
983856
private function getResourceParam(ResourceParam $resourceParam, array $query)
    {
        $uri = $resourceParam->templated === true ? uri_template($resourceParam->uri, $query) : $resourceParam->uri;
        $resource = $this->injector->getInstance(ResourceInterface::class);
        $resourceResult = $resource->get->uri($uri)->eager->request();
        $fragment = parse_url($uri, PHP_URL_FRAGMENT);

        return $resourceResult[$fragment];
    }
1370446
private static function parseUrl(string $url, array $query = [], array $allowedSchemes = ['http' => 80, 'https' => 443]): array
    {
        if (false === $parts = parse_url($url)) {
            throw new InvalidArgumentException(sprintf('Malformed URL "%s".', $url));
        }

        if ($query) {
            $parts['query'] = self::mergeQueryString($parts['query'] ?? null, $query, true);
        }

        $port = $parts['port'] ?? 0;

        if (null !== $scheme = $parts['scheme'] ?? null) {
            if (!isset($allowedSchemes[$scheme = strtolower($scheme)])) {
                throw new InvalidArgumentException(sprintf('Unsupported scheme in "%s".', $url));
            }

            $port = $allowedSchemes[$scheme] === $port ? 0 : $port;
            $scheme .= ':';
        }

        if (null !== $host = $parts['host'] ?? null) {
            if (!\defined('INTL_IDNA_VARIANT_UTS46') && preg_match('/[\x80-\xFF]/', $host)) {
                throw new InvalidArgumentException(sprintf('Unsupported IDN "%s", try enabling the "intl" PHP extension or running "composer require symfony/polyfill-intl-idn".', $host));
            }

            if (false === $host = \defined('INTL_IDNA_VARIANT_UTS46') ? idn_to_ascii($host, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46) : strtolower($host)) {
                throw new InvalidArgumentException(sprintf('Unsupported host in "%s".', $url));
            }

            $host .= $port ? ':'.$port : '';
        }

        foreach (['user', 'pass', 'path', 'query', 'fragment'] as $part) {
            if (!isset($parts[$part])) {
                continue;
            }

            if (false !== strpos($parts[$part], '%')) {
                // https://tools.ietf.org/html/rfc3986#section-2.3
                $parts[$part] = preg_replace_callback('/%(?:2[DE]|3[0-9]|[46][1-9A-F]|5F|[57][0-9A]|7E)++/i', function ($m) { return rawurldecode($m[0]); }, $parts[$part]);
            }

            // https://tools.ietf.org/html/rfc3986#section-3.3
            $parts[$part] = preg_replace_callback("#[^-A-Za-z0-9._~!$&/'()*+,;=:@%]++#", function ($m) { return rawurlencode($m[0]); }, $parts[$part]);
        }

        return [
            'scheme' => $scheme,
            'authority' => null !== $host ? '//'.(isset($parts['user']) ? $parts['user'].(isset($parts['pass']) ? ':'.$parts['pass'] : '').'@' : '').$host : null,
            'path' => isset($parts['path'][0]) ? $parts['path'] : null,
            'query' => isset($parts['query']) ? '?'.$parts['query'] : null,
            'fragment' => isset($parts['fragment']) ? '#'.$parts['fragment'] : null,
        ];
    }
1318486
protected static function preprocessQuery($query, $parameters = [])
    {
        if (is_array($parameters) && count($parameters)) {
            return vsprintf($query, $parameters);
        } else {
            if (isset($parameters)) {
                return sprintf($query, $parameters);
            } else {
                return $query;
            }
        }
    }
911331
public static function setParams($query, array $params = []) {
        Str::assert($query, 'query');

        return array_reduce($params, function($query, $param) {
            $param = self::getStringRepresentation($param);

            return strpos($query, '?') ? substr_replace($query, $param, strpos($query, '?'), strlen('?')) : $query;
        }, $query);
    }
885018
protected function getRequestParameters(Builder $query, array $availableFields)
    {
        $givenFields = $this->getRequestParametersRaw();

        foreach ($givenFields as $fieldName => $value) {

            $from = substr($fieldName, 0, -5);
            $to = substr($fieldName, 0, -3);

            if (in_array($from, $availableFields) && $value != '')
                $query->where($from, '>=', $value);

            if (in_array($to, $availableFields) && $value != '')
                $query->where($to, '<=', $value);

            if (in_array($fieldName, $availableFields))
                if (is_array($value))
                    $query->whereIn($fieldName, $value);
                else
                    $query->where($fieldName, '=', $value);
        }

        return $query;
    }
1341465
public function fetchAssoc($query, array $parameters = array())
    {
        $parameters = $this->parameterTransformer->transform($parameters);
        return $this->db->fetchAssoc($query, $parameters);
    }
128526
public function setFilter(array $allowed = array(), $query = null)
    {
        if (!isset($query)) {
            $query = $this->getFilterQuery();
        }

        $this->setFilterData($allowed, $query);
        $this->query_filter = array_filter($query, 'is_string');
    }
919274
public function query($query, array $binds = array())
    {
        //Argument 1 must be a string or null
        Argument::i()->test(1, 'string', self::QUERY);
        
        $request = new \stdClass();
        
        $request->query = $query;
        $request->binds = $binds;
        
        //event trigger
        $this->trigger('sql-query-before', $request);
        
        $connection = $this->getConnection();
        $query      = (string) $request->query;
        $stmt       = $connection->prepare($query);
        
        //bind some more values
        foreach ($request->binds as $key => $value) {
            $stmt->bindValue($key, $value);
        }
        
        //PDO Execute
        if (!$stmt->execute()) {
            $error = $stmt->errorInfo();
            
            //unpack binds for the report
            foreach ($binds as $key => $value) {
                $query = str_replace($key, "'$value'", $query);
            }
            
            //throw Exception
            Exception::i()
                ->setMessage(Exception::QUERY_ERROR)
                ->addVariable($query)
                ->addVariable($error[2])
                ->trigger();
        }
        
        $results = $stmt->fetchAll(\PDO::FETCH_ASSOC);
        
        if($this->queryCache) {
            //log query
            $this->queries[] = array(
                'query'     => $query,
                'binds'     => $binds,
                'results'   => $results);
        }

        //clear binds
        $this->binds = array();
        
        //event trigger
        $this->trigger('sql-query-after', $query, $binds, $results);
        
        return $results;
    }
1089449
public function replaceQueryParameters($query, $parameters)
    {
        if ($parameters instanceof Data) {
            $parameters = $parameters->getValue(true);
        }

        $i = 0;

        if (! array_key_exists(0, $parameters) && array_key_exists(1, $parameters)) {
            $i = 1;
        }

        return preg_replace_callback(
            '/\?|((?<!:):[a-z0-9_]+)/i',
            static function ($matches) use ($parameters, &$i) {
                $key = substr($matches[0], 1);

                if (! array_key_exists($i, $parameters) && ($key === false || ! array_key_exists($key, $parameters))) {
                    return $matches[0];
                }

                $value  = array_key_exists($i, $parameters) ? $parameters[$i] : $parameters[$key];
                $result = DoctrineExtension::escapeFunction($value);
                $i++;

                return $result;
            },
            $query
        );
    }
125385
public static List<String> findParamsInQuery(String query, boolean changeToLower) {
		List<String> result = new ArrayList<>();

		Matcher matcher = PARAM_PATTERN.matcher(query);

		while (matcher.find()) {
			if (matcher.group("PARAM") != null) {
				String param;
				if (changeToLower) {
					param = matcher.group("PARAM").toLowerCase();
				} else {
					param = matcher.group("PARAM");
				}

				if (!result.contains(param)) {
					result.add(param);
				}
			}
		}

		return result;
	}
622805
private function bindAttributes (&$query, $exclude = array ())
	{
		
		// Loop through attributes
		
		foreach (array_keys (static::$attributes) as $name)
		{
			
			// If we're excluding the attribute then move on
			
			if (in_array ($name, $exclude))
			{
				continue;
			}
			
			// Bind paramater
			
			$query->bindValue (':' . $name, $this->iget ($name));
			
		}
		
	}