@param Query $query

@return mixed
515996
public function search($query)
  {
    $content = $query->getBridgeJson($this->clientKey);

    return $this->query($this->bridgeUrl, $content, self::RESULTS_CLASS);
  }
1153380
public function execute(Query $query)
    {
        $handler = $this->resolveHandler($query);

        return $handler->handle($query);
    }
258264
public function merge(Query $query): Query
    {
        foreach ($query->getCriteria() as $criterion) {
            $criterion->attach($this);
        }

        return $this->attach($query);
    }
891023
public function collStats(Query $query)
    {
        $options = $query->getOptions();

        $cmd     = ['collStats' => $options['table']];
        $command = new Command($cmd);

        $this->log('cmd', 'collStats', $cmd);

        return $command;
    }
356094
protected function get_cache($query){
        return isset($this->query_cache[$query]) ? $this->query_cache[$query] : null;
    }
1291066
public function search($query)
    {
        try {
            $request = $this->client->createRequest($query);
            $response = $this->executeRequest($request);
            $this->hasSearched = true;
            $this->responseCache = $response;
        } catch (HttpException $e) {
            $this->handleErrorResponses($e);
        }
        return $response;
    }
369336
public function pdo(Query $query)
    {
        // 分析查询表达式
        $options = $query->getOptions();

        // 生成查询SQL
        $sql = $this->builder->select($query);

        $bind = $query->getBind();

        if (!empty($options['fetch_sql'])) {
            // 获取实际执行的SQL语句
            return $this->getRealSql($sql, $bind);
        }

        // 执行查询操作
        return $this->query($sql, $bind, $options['master'], true);
    }
342354
protected function getTables(Query $query): array
    {
        $tables = [];

        if (is_string($query->table)) {
            $tables[] = $query->table;
        }

        foreach ($query->join as $join) {
            if (is_string($join->table)) {
                $tables[] = $join->table;
            }
        }

        return $tables;
    }
588537
public function find(Query $query)
    {
        // 分析查询表达式
        $options = $query->getOptions();
        $pk      = $query->getPk($options);

        $data = $options['data'];

        $query->setOption('limit', 1);

        if ($this->cache && empty($options['fetch_sql']) && !empty($options['cache'])) {
            // 判断查询缓存
            $cache = $options['cache'];

            if (is_string($cache['key'])) {
                $key = $cache['key'];
            } elseif (!isset($key)) {
                $key = $this->getCacheKey($query, $data);
            }

            $result = $this->cache->get($key);

            if (false !== $result) {
                return $result;
            }
        }

        if (is_string($pk) && !is_array($data)) {
            if (isset($key) && strpos($key, '|')) {
                list($a, $val) = explode('|', $key);
                $item[$pk]     = $val;
            } else {
                $item[$pk] = $data;
            }
            $data = $item;
        }
        $query->setOption('data', $data);

        // 生成查询SQL
        $sql = $this->builder->select($query);

        $query->removeOption('limit');

        $bind = $query->getBind();

        if (!empty($options['fetch_sql'])) {
            // 获取实际执行的SQL语句
            return $this->getRealSql($sql, $bind);
        }

        // 事件回调
        if ($result = $query->trigger('before_find')) {
        } else {
            // 执行查询
            $resultSet = $this->query($sql, $bind, $options['master'], $options['fetch_pdo']);

            if ($resultSet instanceof \PDOStatement) {
                // 返回PDOStatement对象
                return $resultSet;
            }

            $result = isset($resultSet[0]) ? $resultSet[0] : null;
        }

        if (isset($cache) && $result) {
            // 缓存数据
            $this->cacheData($key, $result, $cache);
        }

        return $result;
    }
1055606
public function rawDelete(Query $query)
        {
            $query->setTable($this);
            $query->generateDeleteSQL();

            $value = Statement::getPreparedStatement($query)->execute();
            $this->clearB2DBCachedObjects();

            return $value;
        }
313252
public function query($query)
    {
        if (is_subclass_of($query, 'Database\Query\QueryAbstract')) {
            return $this->query($this->buildQuery($query));
        }

        $debug = (new Debug\ExecutedQuery($query))->setBacktrace(debug_backtrace());
        $startTime = microtime(true);
        try {
            $result = $this->pdo->query($query);
        } catch (\Throwable $throwable) {
            $debug->setException($throwable);
            throw $throwable;
        } finally {
            $debug->setExecutionTime(microtime(true) - $startTime);
            Debug::addQuery($debug);
        }

        return $this->getPDODatabaseRecord($result);
    }
29066
public function queriedDelete(Query $query)
    {
        $identifier = $this->getIdentifier();
        $queryResult = $this->query($query);
        $deletedIds = [];

        foreach ($queryResult as $record) {
            try {
                $deletedRecord = $this->delete($record[$identifier]);
                $deletedIds[] = $deletedRecord[$identifier];
            } catch (\Throwable $e) {
                // TODO: need to log record that was not deleted
                continue;
            }
        }

        return $deletedIds;
    }
750960
public function apply($query)
    {
        $this->forgetJoins();

        $this->applyParameters($query);

        $this->applyJoins($query);

        return $query;
    }
295061
protected function convertQuery($query)
    {
        if (is_array($query)) {
            return array_map(function ($value) {
                if ($value instanceof Model) {
                    return $value->pk;
                } elseif ($value instanceof Manager || $value instanceof QuerySet) {
                    return $value->getQueryBuilder();
                }

                return $value;
            }, $query);
        } else {
            return $query;
        }
    }
804631
public function printQuery(\Aztech\Skwal\Query $query)
    {
        $this->visit($query);
        
        return $this->queryStack->pop();
    }
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;
                }
            )
        );
    }
460876
public function filter(Query $query)
    {
        if (!empty($this->filterOptions['conditions'])) {
            $query->where($this->filterOptions['conditions']);
        }
        if (!empty($this->filterOptions['order'])) {
            $query->order($this->filterOptions['order']);
        }

        return $query;
    }