convert Query Param to mysql query string
@param QueryCriterionInterface $query
@return string
@throws QueryParsingException
344106
public function convert(QueryCriterionInterface $query) {
        return '' .$this->setPropertyName($query->getName()) . ' ' . $this->getDriverEscaper()->reserved('object') . ' ' . $this->getOperator() . ' ';
    }
1068806
public function process(QueryInterface $query)
    {
        if (!$query instanceof ShowQuery || $query->getObject() !== ShowQuery::EXPRESSION_ENGINES) {
            return null;
        }

        return $this->getResultFromData(self::$data, self::$fields);
    }
623702
public function process(QueryInterface $query)
    {
        if (!$query instanceof ShowQuery || $query->getObject() !== ShowQuery::EXPRESSION_TABLE_STATUS) {
            return null;
        }

        $likeExpr = $query->getLikeExpression();
        $tablet = $this->tablet->getTablet();
        $command = new GetSchema($tablet->getAlias());
        /* @var $vtCtldResult GetSchemaResult */
        $vtCtldResult = $this->client->executeCommand($command);

        return new TableStatus($vtCtldResult, $likeExpr);
    }
786773
protected function parseRQL($query) {
    if (strlen($query) > 0) {
      // replace rql operators
      $operatorMap = ['eq' => '=', 'ne' => '!=', 'lt' => '<', 'lte' => '<=',
          'gt' => '>', 'gte' => '>=', 'in' => 'in', 'match' => 'regexp', '=' => '='];
      $combineMap = ['|' => 'OR', '&' => 'AND'];
      $queryType = $this->getQueryType();
      $mapper = self::getMapper($queryType);
      $persistenceFacade = ObjectFactory::getInstance('persistenceFacade');
      foreach ($operatorMap as $rqlOp => $sqlOp) {
        // add '=' separator for letter-only operators
        $operator = preg_match('/^[a-zA-Z]+$/', $rqlOp) ? '='.$rqlOp.'=' : $rqlOp;
        $query = preg_replace_callback('/([^ <>!=|&\(\)]+) ?'.$operator.' ?([^ <>!=|&\(\)]+)/', function ($match)
                use($rqlOp, $sqlOp, $mapper, $persistenceFacade) {
          $typeAttr = $match[1];
          $value = preg_replace('/^[\'"]|[\'"]$/', '', $match[2]);

          // try to determine value type
          list($typeOrRole, $attribute) = explode('.', preg_replace('/[`"\'\(\)]/', '', $typeAttr), 2);
          $attributeDef = null;
          if ($persistenceFacade->isKnownType($typeOrRole) &&
                  $persistenceFacade->getFullyQualifiedType($typeOrRole) == $mapper->getType() && $mapper->hasAttribute($attribute)) {
            $attributeDef = $mapper->getAttribute($attribute);
          }
          elseif ($mapper->hasRelation($typeOrRole)) {
            $otherMapper = self::getMapper($mapper->getRelation($typeOrRole)->getOtherType());
            $attributeDef = $otherMapper->hasAttribute($attribute) ? $otherMapper->getAttribute($attribute) : null;
          }
          $attributeType = $attributeDef != null ? strtolower($attributeDef->getType()) : null;
          $isNumber = $attributeType == 'integer' || $attributeType == 'float';

          // strip slashes from regexp
          if ($sqlOp === 'regexp') {
            $value = preg_replace('/^\/|\/[a-zA-Z]*$/', '', $value);
          }

          // handle null values
          if ($value === 'null') {
            $sqlOp = $sqlOp == '=' ? 'is' : 'is not';
            $replace = $typeAttr.' '.$sqlOp.' null';
          }
          else {
            // quote value according to type
            $replace = $typeAttr.' '.$sqlOp.' ';
            if ($rqlOp == 'in') {
              $replace .= '('.($isNumber ? $value : join(',', array_map([$mapper, 'quoteValue'], explode(',', $value)))).')';
            }
            else {
              $replace .= $isNumber ? $value : $mapper->quoteValue($value);
            }
          }

          return $replace;
        }, $query);
      }
      foreach ($combineMap as $rqlOp => $sqlOp) {
        $query = str_replace($rqlOp, ' '.$sqlOp.' ', $query);
      }
    }
    return $query;
  }
988926
public function sendSparqlSelectQuery($url, $query)
    {
        // because you can't just fire multiple requests with the same CURL class instance
        // we have to be creative and re-create the class everytime a request is to be send.
        // FYI: https://github.com/php-curl-class/php-curl-class/issues/326
        $class = get_class($this->httpClient);
        $phpVersionToOld = version_compare(phpversion(), '5.5.11', '<=');
        // only reinstance the class if its not mocked
        if ($phpVersionToOld && false === strpos($class, 'Mockery')) {
            $this->httpClient = new $class();
        }

        $this->httpClient->setHeader('Accept', 'application/sparql-results+json');
        $this->httpClient->setHeader('Content-Type', 'application/x-www-form-urlencoded');

        return $this->httpClient->post($url, array('query' => $query));
    }
727999
protected static function normalizeQuery(?string $query): ?string
    {
        if (null === $query) {
            return null;
        }

        if ('' === $query) {
            return '';
        }

        $parts = [];
        $order = [];

        // sort query params by key and remove missing keys
        foreach (explode('&', $query) as $param) {
            if ('' === $param || '=' === $param[0]) {
                continue;
            }
            $parts[] = $param;
            $kvp = explode('=', $param, 2);
            $order[] = $kvp[0];
        }

        array_multisort($order, SORT_ASC, $parts);

        return parent::normalizeQuery(implode('&', $parts));
    }
128446
public function withQuery(string $query): UriInterface
    {
        $query = $this->marshalQueryAndFragment($query);

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

        $instance = clone $this;
        $instance->query = $query;

        return $instance;
    }
1225204
public static function parse($query)
    {
        if (!is_string($query)) {
            throw new InvalidReceivedAuthnRequestQueryStringException(sprintf(
                'Could not parse query string: expected a non-empty string, %s given',
                is_object($query) ? get_class($query) : gettype($query)
            ));
        }

        $queryWithoutSeparator = ltrim($query, '?');

        if (strlen($queryWithoutSeparator) <= strlen('SAMLRequest=')) {
            throw new InvalidReceivedAuthnRequestQueryStringException(sprintf(
                'Could not parse query string: expected a non-empty string of at least %d characters, got "%s"',
                strlen('SAMLRequest='),
                $queryWithoutSeparator
            ));
        }

        $queryParameters = explode('&', $queryWithoutSeparator);

        $parameters = [];
        foreach ($queryParameters as $queryParameter) {
            if (!(strpos($queryParameter, '=') > 0)) {
                throw new InvalidReceivedAuthnRequestQueryStringException(sprintf(
                    'Could not parse "%s": it does not contain a valid key-value pair',
                    $queryParameter
                ));
            }

            list($key, $value) = explode('=', $queryParameter, 2);

            if (!in_array($key, self::$samlParameters)) {
                continue;
            }

            if (array_key_exists($key, $parameters)) {
                throw new InvalidReceivedAuthnRequestQueryStringException(sprintf(
                    'Invalid ReceivedAuthnRequest query string ("%s"): parameter "%s" already present',
                    $queryWithoutSeparator,
                    $key
                ));
            }

            $parameters[$key] = $value;
        }

        if (!isset($parameters[self::PARAMETER_REQUEST])) {
            throw new InvalidReceivedAuthnRequestQueryStringException(sprintf(
                'Invalid ReceivedAuthnRequest query string ("%s"): parameter "%s" not found',
                $queryWithoutSeparator,
                self::PARAMETER_REQUEST
            ));
        }

        if (base64_decode(urldecode($parameters[self::PARAMETER_REQUEST]), true) === false) {
            throw new InvalidRequestException('Failed decoding SAML request, did not receive a valid base64 string');
        }

        $parsedQueryString = new self($parameters[self::PARAMETER_REQUEST]);

        if (isset($parameters[self::PARAMETER_RELAY_STATE])) {
            $parsedQueryString->relayState = $parameters[self::PARAMETER_RELAY_STATE];
        }

        if (isset($parameters[self::PARAMETER_SIGNATURE])) {
            if (!isset($parameters[self::PARAMETER_SIGNATURE_ALGORITHM])) {
                throw new InvalidReceivedAuthnRequestQueryStringException(sprintf(
                    'Invalid ReceivedAuthnRequest query string ("%s") contains a signature but not a signature algorithm',
                    $queryWithoutSeparator
                ));
            }

            if (base64_decode(urldecode($parameters[self::PARAMETER_SIGNATURE]), true) === false) {
                throw new InvalidReceivedAuthnRequestQueryStringException(sprintf(
                    'Invalid ReceivedAuthnRequest query string ("%s"): signature is not base64 encoded correctly',
                    $queryWithoutSeparator
                ));
            }

            $parsedQueryString->signature = $parameters[self::PARAMETER_SIGNATURE];
            $parsedQueryString->signatureAlgorithm = $parameters[self::PARAMETER_SIGNATURE_ALGORITHM];
            return $parsedQueryString;
        }

        if (isset($parameters[self::PARAMETER_SIGNATURE_ALGORITHM])) {
            throw new InvalidReceivedAuthnRequestQueryStringException(sprintf(
                'Invalid ReceivedAuthnRequest query string ("%s") contains a signature algorithm but not a signature',
                $queryWithoutSeparator
            ));
        }

        return $parsedQueryString;
    }
575245
public function apply(QueryObjectInterface $query)
    {
        if (empty($this->fields)) {
            return $this;
        }
        
        $query->where(
            [
                $this->getQueryCondition() => [
                    ':pattern' => "%{$this->pattern}%"
                ]
            ]
        );
        return $this;
    }
545716
public function parse($query)
    {
        $node = new Nodes\RootNode();
        $node->setValue($query);

        $l = new Nodes\UndefinedLogicNode();
        $node->addChild($l);

        $t = new Nodes\TextNode();
        $t->setValue($query);
        $l->addChild($t);

        // $this->addResolver(new Resolvers\TextResolver());

        foreach ($this->resolvers as $token) {
            $token->resolve($node);
        }

        // From Root to Logic
        $node = $node->getChildByIndex(0);

        if ($node === null) {
            throw new Exceptions\QuerySyntaxException($query);
        }

        $node->setParent(null);

        // If logic has only one child, skip to first key node
        if (count($node->getChildren()) === 1) {
            $node = $node->getChildByIndex(0);
            $node->setParent(null);
        }

        if ($node instanceof Nodes\UndefinedLogicNode) {
            throw new Exceptions\QuerySyntaxException($query);
        }

        return $node;
    }
1194842
public function convertToSql(String $query, Parameters $parameterRepository) : StdClass
	{
		$stdClass = new StdClass();
		$stdClass->parameterValues = [];
		$placeholder = '?';
		$stdClass->query = '';
		$match = false;

		if (preg_match_all('/\:([^ ,]+)/s', $query, $matched)) {
			$stdClass->parameterValues = array_map(function($value) use ($parameterRepository, $matched) {
				$value = str_replace(',', '', $value);
				if ($parameterRepository->getParameter($value) == null) {
					throw new InvalidParameterCountException(
						'Number of parameters does not match length of proposed parameters.',
						$matched[1],
						$parameterRepository
					);
				}

				return $parameterRepository->getParameter($value);
			}, $matched[1]);
		}

		$stdClass->query = str_replace($matched[0], '?', $query);

		if (sizeof($stdClass->parameterValues) < 1) {
			$stdClass->parameterValues = array_values($parameterRepository->getAll());
		}

		return $stdClass;
	}
1045537
public function withQueryParams($query): self
    {
        if (!is_string($query)) {
            $query = UriHelper::buildQuery((array) $query);
        }

        return $this->withQuery($query);
    }
1065982
public function process(QueryInterface $query)
    {
        if (!$query instanceof ShowQuery || $query->getObject() !== ShowQuery::EXPRESSION_DATABASES) {
            return null;
        }

        $command = new GetKeyspaces();
        /* @var $vtCtldResult GetKeyspacesResult */
        $vtCtldResult = $this->client->executeCommand($command);

        return new Databases($vtCtldResult);
    }
972185
public function interpret(TokenSequencerInterface $query)
    {
        if (empty($this->metadataProvider)) {
            throw new InterpretationException("Cannot interpret any queries without an Entity Metadata Provider");
        }

        $this->tokenParser->parseTokenSequence($query);

        // select interpreter
        $selectedInterpreter = null;
        $queryType = $query->getType();
        foreach ($this->queryTypeInterpreters as $interpreter) {
            /** @var AbstractSqlQueryTypeInterpreter $interpreter */
            if ($interpreter->supportedQueryType() == $queryType) {
                $selectedInterpreter = $interpreter;
                break;
            }
        }
        if (empty($selectedInterpreter)) {
            throw new InterpretationException("Cannot interpret query. The query type '$queryType' is not supported by any of the installed QueryTypeInterpreters");
        }

        $compiledQuery = new CompiledQuery();
        $compiledQuery->setQuery($selectedInterpreter->interpretQuery($query));
        $compiledQuery->setArguments($selectedInterpreter->getValues());
        $compiledQuery->setPrimaryKeySequence($selectedInterpreter->getPrimaryKeySequence());

        return $compiledQuery;
    }
773748
public function process(QueryInterface $query)
    {
        if (!$query instanceof ShowQuery || $query->getObject() !== ShowQuery::EXPRESSION_FULL_COLUMNS) {
            return null;
        }

        $fromExpr = $query->getFromExpression();

        if (!$fromExpr) {
            throw new Exception('From expression missing.');
        }

        $tablet = $this->tablet->getTablet();
        $schemaCmd = new GetSchema($tablet->getAlias());
        /* @var $result GetSchemaResult */
        $result = $this->client->executeCommand($schemaCmd);

        return new FullColumnsFrom($result, $fromExpr);
    }
625852
function parse_query($query) {
		$operations = array('SELECT','INSERT','UPDATE','DELETE','REPLACE','RENAME','SHOW','SET','DROP','CREATE INDEX','CREATE TABLE','EXPLAIN','DESCRIBE');

		$query_ex = '/(?P<operation>'.implode("|",$operations).')\s*(?P<columns>.?)\s*(FROM|INTO)\s*(?P<table>`?.*?`?)\s*(WHERE)?\s*?(?P<where>.*?)\s*?(ORDER BY)?\s*?(?P<order>.*?)?\s*?(LIMIT)?(?P<limit>.*?)?$/i';
		preg_match($query_ex, $query, $retn);
		return $retn;	
    }
1239630
public function build(QueryInterface $query, QueryBuilder $queryBuilder, ScoringQueryBuilder $scoringQueryBuilder)
    {
        $scoringQueryBuilder->termFrequency($query->getField(), $query->getTerm());
        $scoringQueryBuilder->multiply();
        $scoringQueryBuilder->inverseDocumentFrequency($query->getTerm());
        $scoringQueryBuilder->multiply();
        $scoringQueryBuilder->fieldLengthNorm($query->getField());

        $currentIndex = $this->index++;

        $queryBuilder->setParameter('fieldName_' . $currentIndex, $query->getField());
        $queryBuilder->setParameter('term_' . $currentIndex, $query->getTerm());

        return $queryBuilder->expr()->andX(
            $queryBuilder->expr()->eq('term.term', ':term_' . $currentIndex),
            $queryBuilder->expr()->eq('field.name', ':fieldName_' . $currentIndex)
        );
    }