Executes a specified SOQL query.

@param string $query
@param array  $options

@return array $queryResults
962899
public function query($query, $options = [])
    {
        $url = $this->instanceURLRepo->get();
        $url .= $this->resourceRepo->get('query');
        $url .= '?q=';
        $url .= urlencode($query);

        $queryResults = $this->request($url, $options);

        return $queryResults;
    }
1135335
public function search($query = '', $options = null): ResultSet
    {
        return $this->getType()->search($query, $options = null);
    }
797694
private function executeQuery($document, array $query, array $options)
    {
        $className  = get_class($document);
        $class      = $this->dm->getClassMetadata($className);
        $findQuery  = $this->getQueryForDocument($class, $document);
        $collection = $this->dm->getDocumentCollection($className);
        $collection->update($findQuery, $query, $options);
    }
1150646
public function collectSingleFeed($query, $options = [])
  {
    $feed = $this->getFeed($query, $options);

    return $this->mapByHash($feed);
  }
893263
public function prepare($query, array $options = array())
    {
        // Replace prefix placeholder with prefix
        $query = str_replace("{prefix}", $this->prefix, $query);

        // Log last query and query count
        $this->lastQuery = $query;
        $this->queryCount++;

        // Statement time
        return new Statement($this->connection->prepare($query, $options), $this->connectionName);
    }
687329
public function queryHash($query, $options = array())
    {
        return $this->queryArray(
            $query,
            $options,
            function(\PDOStatement $statement) {
                return $statement->fetchAll(\PDO::FETCH_KEY_PAIR);
            }
        );
    }
839358
public function findFailed(QueryInterface $query, array $options) : QueryInterface
    {
        $query->where([
            'import_id' => $options['import']->id,
            'status' => static::STATUS_FAIL
        ]);

        return $query;
    }
248734
protected function _injectConditions(Query $query, ArrayObject $options, array $fields)
    {
        foreach (array_keys($fields) as $field) {
            $path = $this->getConfig('propertiesMap.' . $field);

            $check = false;
            $query->traverseExpressions(function ($expression) use (&$check, $field, $query) {
                if ($expression instanceof IdentifierExpression) {
                    !$check && $check = $expression->getIdentifier() === $field;

                    return;
                }
                $alias = $this->_table->aliasField($field);
                !$check && $check = preg_match(
                    '/^' . $alias . '/',
                    $expression->sql($query->getValueBinder())
                );
            });

            if (!$check && $value = Hash::get((array)$options, $path)) {
                $query->where([$this->_table->aliasField($field) => $value]);
            }
        }
    }
209955
public function getQuery(array $options = array())
    {
        $query = $this->query;
        $query['query'] = $this->expr->getQuery();
        $query['newObj'] = $this->expr->getNewObj();
        return new Query($this->collection, $query, $options);
    }
1345329
private function _runQuery($query, $options)
    {
        $this->_testQueryStarts($query, '[select|show]');
        $statement = $this->_executeQuery($query, $options);
        if (is_object($statement) && $statement instanceof \PDOStatement) {
            return $statement;
        }
        else {
            $this->_error(FQDBException::INTERNAL_ASSERTION_FAIL, FQDBException::FQDB_CODE);
        }
    }
145272
public function queryTable($query, $options = array())
    {
        return $this->queryArray($query, $options,
            function(\PDOStatement $statement) { return $statement->fetchAll(\PDO::FETCH_ASSOC); }
        );
    }
919329
public function findFilterDataBySlug(Query $query, array $options)
    {
        if (!isset($options['request']) || get_class($options['request']) !== ServerRequest::class) {
            user_error('The request query option must exist and must be of type Cake\Http\ServerRequest.');
        }

        $encryptedFilterData = $this->_findEncryptedFilterData($query, $options['request'])->first();

        if ($encryptedFilterData) {
            $encryptedFilterData = $encryptedFilterData->toArray();
            return $this->_decodeFilterData($encryptedFilterData['filter_data']);
        }

        return [];
    }
84915
public function getNativeQuery(Query $query, array $options = array())
    {
        // Clone the original SimpleExpression
        $statement = clone $query->getStatement();

        // Apply CustomVisitors to modify SimpleExpression
        $customVisitors = $this->getCustomVisitors();
        if($customVisitors) {
            $statement->dispatch($customVisitors);
        }

        // Apply OuterVisitor to output the nativeQuery from SimpleExpression
        $outerVisitor = $this->getOuterVisitor();
        $statement->dispatch($outerVisitor);
        
        // Get NativeQuery from the Visitor
        return $outerVisitor->getNativeQuery($options);
    }
25393
public function output($key = '', $query = '', $options = array())
    {
        // ensure key based retrievals are returned first/fast if empty query.
        if (empty($query) && isset($this->input[$key])) {
            return $this->input[$key];
        }

        // setup standard options.
        if (empty($options)) {
            $options = array('return' => true, 'tags' => true, 'echo' => false);
        }

        // templated output patterns
        $output = $this->templateTextElement($key, $query, $options);

        if (array_key_exists('return', $options)) {
            if ($options['return']) {
                return $output;
            }
        } else {
            return false;
        }
    }
1193907
public function findSlugForFilterData(Query $query, array $options)
    {
        if (!isset($options['request']) || get_class($options['request']) !== ServerRequest::class) {
            user_error('The request query option must exist and must be of type Cake\Http\ServerRequest.');
        }

        if (!isset($options['filterData'])) {
            user_error('No filterData option provided.');
        }

        /** @var ServerRequest $request */
        $request = $options['request'];
        $filterData = $options['filterData'];

        return $query
            ->select($this->getAlias() . '.slug')
            ->where([
                $this->getAlias() . '.controller' => $request->getParam('controller'),
                $this->getAlias() . '.action' => $request->getParam('action'),
                $this->getAlias() . '.filter_data' => $this->_encodeFilterData($filterData)
            ])
            ->where($this->_pluginCondition($request));
    }
490952
public function findWithTrashed(Query $query, array $options)
    {
        return $query->where(['OR' => [
            $query->newExpr()->isNotNull($this->getTrashField()),
            $query->newExpr()->isNull($this->getTrashField()),
        ]]);
    }
1199258
public function read($query, array $options = []) {
		$defaults = ['return' => 'resource', 'model' => $query->model()];
		$options += $defaults;
		$params = compact('query', 'options');

		return Filters::run($this, __FUNCTION__, $params, function($params) {
			$query = $params['query'];
			$params = $query->export($this);

			list($_path, $conditions) = (array) $params['conditions'];
			$model = $query->model();

			if (empty($_path)) {
				$_path = '_all_docs';
				$conditions['include_docs'] = 'true';
			}
			$path = "{$this->_config['database']}/{$_path}";
			$args = (array) $conditions + (array) $params['limit'] + (array) $params['order'];

			$result = $this->connection->get($path, $args);
			$result = is_string($result) ? json_decode($result, true) : $result;

			$data = $stats = [];

			if (isset($result['_id'])) {
				$data = [$result];
			} elseif (isset($result['rows'])) {
				$data = $result['rows'];
				unset($result['rows']);
				$stats = $result;
			}
			$stats += ['total_rows' => null, 'offset' => null];
			$opts = compact('stats') + [
				'class' => 'set', 'exists' => true, 'defaults' => false
			];

			return $this->item($model, $data, $opts);
		});
	}