Prepare query parameters

@return [type]
197669
protected function prepareParams()
    {
        $params = [];

        if ( ! empty($this->_where) && is_array($this->_where)) {
            $params['filters'] = $this->_where;
        }

        if ( ! empty($this->_offset)) {
            $params['offset'] = $this->_offset;
        }

        if ( ! empty($this->_limit)) {
            $params['limit'] = $this->_limit;
        }

        if ( ! empty($this->_orders) && is_array($this->_orders)) {
            foreach ($this->_orders as $field => $order) {
                $params['order_by'][$field] = $order;
            }
        }

        return $params;
    }
330165
def parse_uri_query_params(query)
      query.to_s.split('&'.freeze).reduce({}) do |h, p|
        k, v = p.split('='.freeze, 2)
        v = URI::Generic::DEFAULT_PARSER.unescape(v) if v
        h[k.to_sym] = v || true
        h
      end
    end
268297
private function build_query() {
        if (!empty($this->_query)) {
            return $this->_query;
        }

        $query = array();
        foreach ($this->_query_terms as $k => $v) {
            $query[] = "$k:$v";
        }
        return implode(' AND ', $query);
    }
503981
def filter_params
      @_filter_params ||=
        case params[:filter]
        when Hash, ActionController::Parameters
          default_filters.each_with_object({}) do |field, hash|
            unformatted_field = @request.unformat_key(field)
            hash[unformatted_field] = params[:filter][field]
          end
        end
    end
892403
private function prepare($query, $parameters)
    {
        if (!$parameters) {
            $parameters = array();
        } elseif (!is_array($parameters)) {
            $parameters = array($parameters);
        }

        $this->paramNb = 0;
        $this->params = & $parameters;
        $query = preg_replace_callback('/\?/', array($this, 'replaceParam'), $query);

        return $query;
    }
1193735
protected function prepareQueryAndParams(string $query, array $params): array
	{
		// Replace IN clause placeholder with escaped values

		replace:

		if(strpos($query, '([?])') !== false)
		{
			foreach($params as $key => $value)
			{
				if(is_array($value))
				{
					array_splice($params, $key, 1, $value);

					$query = preg_replace('/\(\[\?\]\)/', '(' . trim(str_repeat('?, ', count($value)), ', ') . ')', $query, 1);

					goto replace;
				}
			}
		}

		// Return query and parameters

		return [$query, $params];
	}
385341
function makeQuery()
    {
        $query = array();
        foreach($this->query as $paramater) {
            $operator = ($paramater[1] != '=') ? $paramater[1] : '' ;
            $query[$paramater[0] . $operator] = $paramater[2];
        }
        return $query;
    }
459678
public function getQueryParams()
    {
        if (is_array($this->query)) {
            return $this->query;
        }

        if ($this->uri === null) {
            return [];
        }

        parse_str($this->uri->getQuery(), $this->query);

        return $this->query;
    }
1373667
private function processParameters()
    {
        $parameters = $this->parameters;
        $string = $this->query;

        $string = str_replace('[:', '[;;', $string);

        $parameters = array_filter($parameters, function ($value) use (& $parameters, & $string)
        {
            $key = key($parameters);
            next($parameters);

            if (is_numeric($value))
            {
                $string = str_replace(":$key", $value, $string);
                return false;
            }

            else
            {
                $string = str_replace(":$key", '{' . $key . '}', $string);
                return true;
            }
        });

        $string = str_replace('[;;', '[:', $string);

        $this->query = $string;
        return $parameters;
    }
105506
public function makeQuery()
    {
        $data = $this->q;

        $params = array();
        $query = "SELECT ";

        if (isset($data['from']['columns'])) {
            foreach ($data['from']['columns'] as $key => $value) {
                $query .= "$value, ";
            }

            $query = substr($query, 0, -2);
        } else {
            $query .= "{$data['from']['table']}.* ";
        }

        // Join columns
        if (isset($data['join'])) {
            foreach ($data['join'] as $join) {
                if (isset($join['columns'])) {
                    foreach ($join['columns'] as $col) {
                        $query .= ", {$join['table']}.{$col}";
                    }
                } else {
                    $query .= ", {$join['table']}.*";
                }

            }
        }

        $query .= " FROM {$data['from']['table']}";

        // Join
        if (isset($data['join'])) {
            foreach ($data['join'] as $join) {
                $query .= " JOIN {$join['table']} ON {$join['conditions']}";

            }
        }

        if (isset($data['where'])) {
            $query .= " WHERE (";

            $iWhere = 0;
            foreach ($data['where'] as $key => $value) {
                if (!is_int($key)) {
                    $query .= "$key = :where$iWhere AND ";
                    $params[":where$iWhere"] = $value;
                    $iWhere++;
                } else {
                    $query .= "$value AND";
                }

            }

            $query = substr($query, 0, -4);

            $iWhereO = 0;
            if (isset($data['orwhere'])) {
                foreach ($data['orwhere'] as $key => $value) {
                    if (!is_int($key)) {
                        $query .= " OR $key = :whereO$iWhereO ";
                        $params[":whereO$iWhereO"] = $value;
                        $iWhereO++;
                    } else {
                        $query .= "OR $value ";
                    }
                }
            }
            $query .= ")";
        }

        if (isset($data['group'])) {
            $query .= " GROUP BY :group";
            $params[':group'] = $data['group'];
        }

        $iOrder = 0;
        if (isset($data['order'])) {
            $query .= " ORDER BY ";
            foreach ($data['order'] as $key => $value) {
                $query .= ":order$iOrder $value";
                $params[":order$iOrder"] = $key;
                $iOrder++;
            }
        }

        if (isset($data['limit'])) {
            $query .= " LIMIT :limit";
            $params[":limit"] = $data['limit']['limit'];
            if (isset($data['limit']['offset'])) {
                $query .= ", :offset";
                $params[":offset"] = $data['limit']['offset'];
            }
        }

        return ['query' => $query, 'params' => $params];
    }
283197
protected function _prepare_filter() {
		$term = \get_queried_object();

		if ( ! empty( $term->slug ) && ! empty( $term->taxonomy ) ) {
			$this->term     = $term->slug;
			$this->taxonomy = $term->taxonomy;
		}
	}
696125
public function whereParameters()
    {
        return array_filter(
            $this->queryParameters,
            function ($queryParameter) {
                $key = $queryParameter['key'];
                return (! in_array($key, $this->predefinedParams));
            }
        );
    }
508113
protected function prepareQuery($query)
    {
        $query = $query->with($this->withs);

        if ($this->withCounts) {
            $query = $query->withCount($this->withCounts);
        }

        if ($this->orderBy) {
            $query = $query->orderBy($this->orderBy, $this->orderByDirection);
        }

        if ( ! empty($this->has)) {
            foreach ($this->has as $has) {
                $query = $query->has($has['relation'], $has['operator'], $has['value']);
            }
        }

        if ( ! empty($this->whereHas)) {
            foreach ($this->whereHas as $has) {
                $query = $query->whereHas($has[0], isset($has[1]) ? $has[1] : null);
            }
        }

        return $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;
    }
693692
private function prepareData()
    {
        $data = [];
        foreach (get_object_vars($this) as $property => $value) {
            if (in_array($property, ['apiHost', 'debug'])) {
                continue;
            }

            if ($property == 'format') {
                $data[$value] = '';
            } elseif (is_bool($value) && $value) {
                $data[$property] = '';
            } elseif (!is_null($value) && !is_bool($value)) {
                if (is_array($value)) {
                    foreach ($value as $key => $val) {
                        $value[$key] = $val;
                    }
                } else {
                    $value = $value;
                }

                $data[$property] = $value;
            }
        }

        if (empty($data) && $this->debug) {
            throw new \Exception('Query have not data');
        }

        $data = http_build_query($data);

        return $data;
    }
821604
function prepareQueryParams(endpointSchema) {
  const isSendInQuery = p => p.in === 'query';
  const parameters = endpointSchema.parameters || [];
  const queryParameters = parameters.filter(isSendInQuery);
  return convertParameters(queryParameters);
}
1363045
public function prepareSearchParam() {
        if (isset($this->request['searchFields']) and ! empty($this->request['searchFields'])) {
            $returnSearch = Array();
            $countSearchFields = 0;

            foreach ($this->request['searchFields'] as $key => $value) {
                $returnSearch[$countSearchFields]['indexColumn'] = $key;
                $returnSearch[$countSearchFields]['valueColumn'] = $value;
                $countSearchFields++;
            }
            return $returnSearch;
        } else {
            return null;
        }
    }