Convert the string query into an object (e.g.).

@param string $query (e.g.) title eq 'something'

@return \Railken\SQ\Contracts\NodeContract
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;
    }
621076
public function withQuery($query)
    {
        $new = clone $this;
        try {
            $new->setQuery($query);
        } catch (InvalidArgumentException $ex) {
            throw new InvalidArgumentException('Invalid query provided.', null, $ex);
        }

        return $new;
    }
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;
    }
253249
public function setQuery($query)
    {
        if (is_string($query) || $query instanceof \OtherCode\Database\Query\Query) {
            $this->query = $query;
        }
        return $this;
    }
1045537
public function withQueryParams($query): self
    {
        if (!is_string($query)) {
            $query = UriHelper::buildQuery((array) $query);
        }

        return $this->withQuery($query);
    }
1144547
protected static function encodeQuery(string $query): string
    {
        // http://tools.ietf.org/html/rfc3986#section-3.4
        // query = *( pchar / "/" / "?" )
        // pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
        $excluded = static::UNRESERVED_SET.static::SUB_DELIMS_SET.':@\/\?';

        return static::encode($query, $excluded);
    }
615391
public static function fromQueryString($query)
    {
        if (is_string($query)) {
            parse_str($query, $query);
        }
        if (empty($query)) {
            return null;
        }
        // Check date
        $archiveDate = isset($query['archiveDate']) && strtotime($query['archiveDate'])
            ? $query['archiveDate']
            : null;

        // Check stage (ignore invalid stages)
        $stage = null;
        if (isset($query['stage']) && strcasecmp($query['stage'], Versioned::DRAFT) === 0) {
            $stage = Versioned::DRAFT;
        } elseif (isset($query['stage']) && strcasecmp($query['stage'], Versioned::LIVE) === 0) {
            $stage = Versioned::LIVE;
        }

        // Archive date is specified
        if ($archiveDate) {
            // Stage defaults to draft archive
            $stage = $stage ?: Versioned::DRAFT;
            return 'Archive.' . $archiveDate . '.' . $stage;
        }

        // Stage is specified by itself
        if ($stage) {
            return 'Stage.' . $stage;
        }

        // Unsupported query mode
        return null;
    }
1170056
public function transform($query) {
        $usePatch = isset($this->options['driverOptions']['use_patch']) ? $this->options['driverOptions']['use_patch'] : false;
        
        $tokens     = $this->parser->parse($query);
        $method     = HttpMethods::ofSqlOperation(SqlOperation::create($tokens), $usePatch);
        $annotation = Annotation::get($this->routings, Table::create($tokens), $method);

        return $this->requestFactory->createOne($method, $tokens, $this->options, $annotation);
    }
940666
protected function execute($query)
    {
        $query->execute($this->bindings);
        
        $this->bindings = [];
        $this->wheres   = [];

        return $query;
    }
1146840
public function newEloquentBuilder($query)
    {
        return \tap(new Builder($query), function ($builder) {
            $builder->setTenantor($this->tenantor ?? null);
        });
    }
648741
protected function createSub($query)
    {
        // If the given query is a Closure, we will execute it while passing in a new
        // query instance to the Closure. This will give the developer a chance to
        // format and work with the query before we cast it to a raw SQL string.
        if ($query instanceof Closure) {
            $callback = $query;

            $callback($query = $this->forSubQuery());
        }

        return $this->parseSub($query);
    }
975287
public function join($query)
    {
        $clause = '';
        $repository = $query->getRepository();
        $resources = $repository->getResources();
        $links = $resources->getLinks();
        foreach ($links as $link) {
            $type = strtoupper($link->resource->getLinkType());
            switch ($type) {
                case 'STRONG' : $type = 'INNER';break;
                case 'WEAK'   : $type = 'LEFT'; break;
            }
            $query->join($type, $link->resource->getName().' AS '.$this->_store->quoteName($link->resource->getAlias()), array(
                $link->child.'='.$link->parent,
            ));
        }

        $this->_links($query, $query->link);

        if (!empty($query->join)) {
            $joins = array();
            foreach ($query->join as $join) {
                $tmp = '';

                if (!empty($join['type'])) {
                    $tmp .= $join['type'].' ';
                }

                $tmp .= 'JOIN '.$join['resource'];
                $tmp .= ' ON '.implode(' AND ', $join['condition']);

                $joins[] = $tmp;
            }

            $clause = implode(' ', $joins);
        }

        return $clause;
    }
385206
public function buildQuery($query)
    {
        $q = $this->request->getQuery();

        foreach ($query as $key => $value)
        {
            $q[$key] = $value;
        }
    }
315339
private function makeQueryString($query = array())
	{
		$subject = $query[0];
		$operator = $query[1];
		$operand = $query[2];

		switch ($operator)
		{
			case '=':
				$string = $subject . ':' . $operand;
			break;
		}

		return $string;
	}
1319104
private function executeQuery($query) {
		$content = (string)$this->getAdapter()->get($query)->getBody();
		if (empty($content)) {
			throw new NoResult(sprintf('Could not execute query %s', $query));
		}

		$data = Xml::build($content);
		if (empty($data) || empty($data->result)) {
			throw new NoResult(sprintf('Could not execute query %s', $query));
		}

		$data = (array)$data->result;

		$adminLevels = [];

		if (!empty($data['isp']) || !empty($data['isp'])) {
			$adminLevels[] = [
				'name' => isset($data['isp']) ? $data['isp'] : null,
				'code' => null,
				'level' => 1
			];
		}

		return $this->returnResults([
			array_merge($this->getDefaults(), [
				'latitude' => isset($data['latitude']) ? $data['latitude'] : null,
				'longitude' => isset($data['longitude']) ? $data['longitude'] : null,
				'locality' => isset($data['city']) ? $data['city'] : null,
				'adminLevels' => $adminLevels,
				'country' => isset($data['countryname']) ? $data['countryname'] : null,
				'countryCode' => isset($data['countrycode']) ? $data['countrycode'] : null,
			])
		]);
	}
332589
protected function exec($query)
    {
        if (!$query) {
            throw new Exceptions\RPCException("Empty query.");
        }
        
        $url = sprintf("http://%s:%d", $this->conf["host"], $this->conf["port"]);
        $web = $this->getWebClient();
        $web->setMethod(HttpMethods::POST);
        $web->addHeader("Content-Type", "application/json");
        $web->setBasicAuth($this->conf["user"], $this->conf["pass"]);
        $web->setData($query);
        $response    = $web->request($url);
        $status_code = $response->getCode();
        
        if (isset(self::$exceptions[$status_code])) {
            $error = $this->getResponseError($response, $status_code);
            throw new self::$exceptions[$status_code](
                $error["message"],
                $error["code"]
            );
        }

        return $response;
    }
1209891
public function setQuery($query)
    {
        $this->dispatcher
            ->dispatch(DataGridEvents::onQueryReady, new QueryEvent($this->dataGrid->getName(), $query));
        
        $this->query = $query;
        
        return $this;
    }