Build query string

@param array|null $query
@return null|string
425791
protected function getQueryString(?array $query) : ?string
    {
        if (empty($query)) {
            return null;
        }

        return '?' . http_build_query($query, null, '&', PHP_QUERY_RFC3986);
    }
798320
public static function buildQueryString(array $data = null, $urlEncode = true)
    {
        if ($data === null) {
            $data = static::$get;
        }

        $query = [];

        foreach ($data as $name => $value) {
            $query[] = "{$name}=" . ($urlEncode ? urlencode($value) : $value);
        }

        if (count($query)) {
            return '?' . implode('&', $query);
        }
    }
1164199
protected function getQueryString($query)
    {
        $wrapper = ($query instanceof AbstractQuery) ? array('query' => $query->toArray()) : $query->toArray();

        return json_encode($wrapper);
    }
906756
public static function canonquery($query, $prefix = '')
    {
        parse_str(preg_replace('#^\?#', '', $query), $args);

        if (empty($args)) {
            return '';
        }

        ksort($args);
        return $prefix . http_build_query($args);
    }
1331985
protected static function parseQuery($query)
    {
        if (is_array($query))
            return $query;

        if (empty($query))
            return null;

        if (!is_string($query))
            throw new \InvalidArgumentException('Query must be associative array or string');
        
        $query = ltrim($query, '?');
        $query = str_replace('&amp;', '&', $query);
        $parts = explode('&', $query);
        $values = [];
        foreach ($parts as $part)
        {
            $subparts = explode('=', $part, 2);
            if (count($subparts) === 1)
                $values[$part] = '1';
            else
                $values[$subparts[0]] = $subparts[1];
        }

        return empty($values) ? null : $values;
    }
981566
public function buildQueryString($args = array()) {
		$args = array_merge($args, array("token" => $this->token));
		
		$query = "";
		if (isset($args)) {
			while (list($key, $val) = each($args)) {
				if ( strlen($query) > 0 ) {
					$query .= "&";
				} else {
					$query .= "?";
				}
				$query .= $key . '=' . $val;
			}
		}
		return $query;
	}
1054659
public function build(&$query)
    {
        if (isset($query['uniqueAlias'])) {
            $query['id'] = $query['uniqueAlias'];
            unset($query['uniqueAlias']);
        }

        return parent::build($query);
    }
476283
public function buildQuery(QueryAbstract $query)
    {
        $queryParts = $query->getQueryParts();
        return implode(
            ' ',
            array_filter(
                [
                    $queryParts['type'],
                    $this->getFields($queryParts),
                    $this->getTable($queryParts),
                    $this->getSet($queryParts),
                    $this->getValues($queryParts),
                    $this->getJoins($queryParts),
                    $this->getWhere($queryParts),
                    $this->getGroup($queryParts),
                    $this->getOrder($queryParts),
                    $this->getLimit($queryParts)
                ],
                function ($var) {
                    return $var !== null;
                }
            )
        );
    }
1367092
public function path($path, $query = null)
    {
        $uri = $this->request()->getUri();
        $uri = $uri->withPath($path);
        if ($query) {
            $uri = $uri->withQuery($query);
        }
        return (string) $uri;
    }
14814
private function filterQuery(string $query): string
    {
        if ($query !== '' && $query[0] === '?') {
            $query = \substr($query, 1);
        }

        $parts = \explode('&', $query);
        foreach ($parts as $index => $part) {
            [$key, $value] = $this->splitQueryValue($part);
            if ($value === null) {
                $parts[$index] = $this->filterQueryOrFragment($key);
                continue;
            }

            $parts[$index] = $this->filterQueryOrFragment($key) . '=' . $this->filterQueryOrFragment($value);
        }

        return implode('&', $parts);
    }
1166194
protected function buildQueryString($query)
    {
        if (defined('PHP_QUERY_RFC3986')) {
            return http_build_query($query, null, '&', PHP_QUERY_RFC3986);
        }

        // @codeCoverageIgnoreStart
        return str_replace('+', '%20', http_build_query($query, null, '&'));
        // @codeCoverageIgnoreEnd
    }
414870
public function fullUrlWithQuery( array $query )
	{
		return count( $this->query() ) > 0 ? $this->url() . '/?' . http_build_query( array_merge( $this->query(), $query ) ) : $this->fullUrl() . '?' . http_build_query( $query );
	}
1290283
public static function query_string($request = null)
    {
        if (!$request) {
            $request = Controller::curr()->Request;
        }

        if (!$request) {
            return '';
        }

        $vars = $request->getVars();
        if (isset($vars['url'])) {
            unset($vars['url']);
        }

        return empty($vars) ? '' : '?' . http_build_query($vars);
    }
918917
public function setQuerystring(string $query = null) : self
    {
        if (is_null($query)) {
            $this->uri['query'] = [];
        } else {
            $this->uri['query'] = $this->parseStr($query);
        }

        return $this;
    }
687103
public function getSearchRequestMeta(Array $query = NULL) {
    if (!isset($this->searchRequestMeta)) {
      $this->searchRequestMeta = new RequestMeta(\Psc\Net\HTTP\Request::GET,
                                               $this->constructUrl(array($this->getEntityNamePlural(), '%s')),
                                               array(RequestMeta::QUERY)
                                              );
    }
    
    if (isset($query)) {
      $meta = clone $this->searchRequestMeta;
      return $meta->setInput($query);
    }
    return $this->searchRequestMeta;
  }
543421
private function buildQuery($array)
    {
        $result = '';
        foreach ($array as $key => $value) {
            if (!$value)
                continue;
            if ($result)
                $result .= '&';
            if (is_array($value)) {
                foreach ($value as $subValue) {
                    if ($result)
                        $result .= '&';
                    $result .= urlencode($key) . '=' . urlencode($subValue);
                }
            } else {
                $result .= urlencode($key) . '=' . urlencode($value);
            }
        }
        return $result;
    }
432281
private function postProcessHttpQueryString(string $query, array $data): string
    {
        if ($this->getEncodeArraysUsingDuplication()) {
            $query = preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '=', $query);
        }

        if (!is_null($processor = $this->getHttpQueryCustomProcessor())) {
            $query = $processor($query, $data);
        }

        return $query;
    }