@param Query $query

@return bool|\Colibri\Database\AbstractDb\Driver\Query\ResultInterface

@throws \Colibri\Database\DbException
@throws \Colibri\Database\Exception\SqlException
@throws \UnexpectedValueException
979897
protected function doQuery(Query $query)
    {
        $result = static::db()->query($query);

        $this->where = null;

        return $result;
    }
23785
public function apply(Query $query) : Query
    {
        return $query->where(
            (new QueryExpression())->gt(
                $this->field,
                $this->value,
                $query->getTypeMap()->type($this->field)
            )
        );
    }
178205
public function execQuery(Query $query)
    {
        $this->connection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
        $this->connection->setAttribute(\PDO::ATTR_EMULATE_PREPARES, $query->isSingle());
        $resultDataType = $query->getResultDataType();

        foreach ($query as $sql) {
            $sqlResult = $sql->getResult();
            if ($resultDataType instanceof DataInterface) {
                $sqlResult->setDataType($resultDataType);
            }

            try {
                if ($this->error->hasError()) {
                    throw new \PDOException($this->error->getMessage());
                    break;
                }
                $sqlQuery = $sql->toString();
                $totalRows = 0;
                if ($sql->getCommand() == 'SELECT' && !$query->isSingle()) {
                    $template = '{SQL}';
                    $templateCounter = 'SELECT COUNT(*) totalRows FROM (%s) fakeTable';
                    $templateParams = array(
                        'SQL' => $sqlQuery,
                        'LIMIT' => $query->getLimit(),
                        'OFFSET' => $query->getOffset(),
                    );
                    if ($query->getLimit()) {
                        switch ($this->config->getType()) {
                            case 'firebird':
                                $template = 'SELECT FIRST {LIMIT} SKIP {OFFSET} * FROM ({SQL}) fakeTable';
                            break;
                            case 'oci':
                                $templateCounter = 'SELECT COUNT(*) "totalRows" FROM (%s) "fakeTable"';
                                $template = 'SELECT a.* FROM (SELECT b.*, rownum "[]" FROM '.
                                            '({SQL}) b WHERE rownum <= {LIMIT}) a WHERE "[]" > {OFFSET}';
                            break;
                            default:
                                $template = 'SELECT * FROM ({SQL}) fakeTable LIMIT {LIMIT} OFFSET {OFFSET}';
                            break;
                        }
                    }

                    $resultCounter = $this->connection->prepare(sprintf($templateCounter, $sqlQuery));
                    $resultCounter->execute();
                    $totalRows = $resultCounter->fetch();

                    $sqlResult->setTotalRows((int) @$totalRows['totalRows']);
                    foreach ($templateParams as $key => $val) {
                        $template = str_replace('{'.$key.'}', $val, $template);
                    }
                    $sqlQuery = $template;
                }

                $result = $this->connection->prepare($sqlQuery);
                $stmt = $result->execute();
                $sql->execute();

                if ($sql->isRead()) {
                    $columns = $this->_define_column_types($result);

                    $sqlResult->setColumnTypes($columns);
                    $sqlResult->setAffected(0);
                    $sqlResult->setStartRow($query->getOffset());
                    if (!$sqlResult->getTotalRows()) {
                        $sqlResult->setTotalRows($result->rowCount());
                    }

                    $rows = $result->fetchAll(\PDO::FETCH_ASSOC);

                    foreach ($rows as $row) {
                        $data = $this->_merge_values($sql->getResult()->getDataType(), $row, $columns);
                        $sqlResult->add($data);
                    }

                    $sqlResult->setTotalShows($sqlResult->length());
                    $sqlResult->setEnd(microtime(true));
                } elseif ($sql->isWrite() || $sql->isDDL()) {
                    $insertId = $this->connection->lastInsertId();
                    $affected = $result->rowCount();
                    $endTime = microtime(true);
                    $sqlResult->setEnd($endTime);

                    $columns = array(
                        'affected' => 'integer',
                        'seconds' => 'double',
                    );

                    $row = array(
                        'affected' => $affected,
                        'seconds' => $sqlResult->getSeconds(),
                    );

                    $sqlResult->setColumnTypes($columns);
                    $sqlResult->setAffected($affected);

                    $data = new Data();
                    $this->_merge_values($data, $row, $columns);
                    $sqlResult->add($data);
                    $sqlResult->setInsertId($insertId);
                }
            } catch (\PDOException $e) {
                $sql->execute(false);
                $this->error->setMessage($e->getMessage().". \n".$sql->toString());
                $sqlResult->setEnd(microtime(true));
            } catch (\Exception $e) {
                $sql->execute(false);
                $this->error->setMessage($e->getMessage().". \n".$sql->toString());
                $sqlResult->setEnd(microtime(true));
            }
        }
    }
647158
final public function handle(Query $query): DTO
    {
        $supportedQueryType = $this->getSupportedQueryType();
        if (!\is_a($query, $supportedQueryType)) {
            throw new InvalidQueryException(\sprintf(
                'Query command must be a %s, %s given',
                $supportedQueryType,
                \get_class($query)
            ));
        }

        return $this->handleQuery($query);
    }
1228247
private function query($query)
    {
		if(!is_array($query)) {
			return q($query);
		} else {
			foreach($query as $v) {
				q($v);
			}
			return true;
		}
    }
611340
public function execute(Query $query, array $options = [])
    {
        $result = $this->_executeQuery($query, $options);

        if ($this->getDriver() === null) {
            throw new \UnexpectedValueException(__('No driver has been defined'));
        }

        // Write to the logger when one has been defined
        if ($this->getDriver()->getLogger()) {
            $this->_logQuery($query, $this->getDriver()->getLogger());
        }

        return $result;
    }
646594
public function delete(Query $query)
    {
        $options = $query->getOptions();

        return str_replace(
            ['%TABLE%', '%USING%', '%JOIN%', '%WHERE%', '%ORDER%', '%LIMIT%', '%LOCK%', '%COMMENT%'],
            [
                $this->parseTable($query, $options['table']),
                !empty($options['using']) ? ' USING ' . $this->parseTable($query, $options['using']) . ' ' : '',
                $this->parseJoin($query, $options['join']),
                $this->parseWhere($query, $options['where']),
                $this->parseOrder($query, $options['order']),
                $this->parseLimit($query, $options['limit']),
                $this->parseLock($query, $options['lock']),
                $this->parseComment($query, $options['comment']),
            ],
            $this->deleteSql);
    }
91161
public function query($query)
    {
        $results = $this->connection->{$this->type}(
            $this->getDn(),
            $query,
            $this->getSelects(),
            $onlyAttributes = false,
            $this->limit
        );

        return $this->newProcessor()->process($results);
    }
1216840
protected function setKeysForSaveQuery(Query $query)
    {
        $query->where($this->morphType, $this->morphClass);

        return parent::setKeysForSaveQuery($query);
    }
1153380
public function execute(Query $query)
    {
        $handler = $this->resolveHandler($query);

        return $handler->handle($query);
    }
1035680
public function driver(Query $query)
    {
        $conn = $query->connection(null);
        list(, $driver) = namespaceSplit(strtolower(get_class($conn->driver())));

        return $driver;
    }
1068806
public function process(QueryInterface $query)
    {
        if (!$query instanceof ShowQuery || $query->getObject() !== ShowQuery::EXPRESSION_ENGINES) {
            return null;
        }

        return $this->getResultFromData(self::$data, self::$fields);
    }
353431
public function interpret(Query $query)
    {
        switch ($query->getAction()) {
            case Query::ACTION_FIND:
                /** @var FindQuery $query */
                return $this->compileFindQuery($query);
            case Query::ACTION_INSERT:
                /** @var InsertQuery $query */
                return $this->compileInsertQuery($query);
            case Query::ACTION_UPDATE:
                /** @var UpdateQuery $query */
                return $this->compileUpdateQuery($query);
            case Query::ACTION_DELETE:
                /** @var DeleteQuery $query */
                return $this->compileDeleteQuery($query);
            default:
                throw new QueryException("Invalid query action: {$query->getAction()}");
        }
    }
699765
public function executeRawQuery($query)
    {
        $resultSet = null;
        if($this->odbAdapter) {
            if(!empty($query)) {
                $resultSet = $this->getDbAdapter()->query($query, DbAdapter::QUERY_MODE_EXECUTE);

            }
        }


        return $resultSet;
    }
939890
public function buildQuery(QueryInterface $query)
    {
        $searchQuery = false;
        $builder     = $this->getBuilder($query);

        if ($builder !== null) {
            $searchQuery = $builder->buildQuery($query);
        }

        return $searchQuery;
    }
1342987
public function process(QueryInterface $query)
    {
        if (!$query instanceof ShowQuery || $query->getObject() !== ShowQuery::EXPRESSION_CREATE_DATABASE) {
            return null;
        }

        $database = $query->getCreateObjectExpression(ShowQuery::EXPRESSION_CREATE_DATABASE);

        $newData = [];
        $newData[] = array_map(function ($row) use ($database) {
            return str_replace('{DB}', $database, $row);
        }, self::$data);

        return $this->getResultFromData($newData, self::$fields);
    }
918264
public function getValue($query)
    {
        $this->statement = $this->db->query($query);
        if ($this->statement) {
            $value = $this->statement->fetch(\PDO::FETCH_BOTH);
            if (!empty($value[0])) {
                return $value[0];
            }
        }
        return false;
    }