Skip to content

Commit

Permalink
Added Doctrine DBAL 4 support (#69)
Browse files Browse the repository at this point in the history
* Added support for doctrine/dbal ^4.
  • Loading branch information
pschombara authored Sep 26, 2024
1 parent 57c4676 commit f7d0dda
Show file tree
Hide file tree
Showing 19 changed files with 446 additions and 530 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"php": "^8.0",
"ext-pcre": "*",
"ext-mbstring": "*",
"doctrine/dbal": "^3.0",
"doctrine/dbal": "^4.0",
"smi2/phpclickhouse": "^1.0"
},
"require-dev": {
Expand Down
35 changes: 17 additions & 18 deletions src/ClickHouseConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@
use ClickHouseDB\Exception\ClickHouseException;
use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\Driver\Result;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\AbstractPlatform;

use Doctrine\DBAL\Platforms\Exception\NotSupported;
use function array_merge;

class ClickHouseConnection implements Connection, ServerInfoAwareConnection
class ClickHouseConnection implements Connection
{
protected Client $client;

Expand Down Expand Up @@ -69,13 +67,9 @@ public function query(string $sql): Result
/**
* {@inheritDoc}
*/
public function quote($value, $type = ParameterType::STRING)
public function quote(string $value): string
{
if ($type === ParameterType::STRING) {
return $this->platform->quoteStringLiteral($value);
}

return $value;
return $this->platform->quoteStringLiteral($value);
}

/**
Expand All @@ -89,33 +83,33 @@ public function exec(string $sql): int
/**
* {@inheritDoc}
*/
public function lastInsertId($name = null)
public function lastInsertId(): int|string
{
throw Exception::notSupported(__METHOD__);
throw NotSupported::new(__METHOD__);
}

/**
* {@inheritDoc}
*/
public function beginTransaction(): bool
public function beginTransaction(): void
{
throw Exception::notSupported(__METHOD__);
throw NotSupported::new(__METHOD__);
}

/**
* {@inheritDoc}
*/
public function commit(): bool
public function commit(): void
{
throw Exception::notSupported(__METHOD__);
throw NotSupported::new(__METHOD__);
}

/**
* {@inheritDoc}
*/
public function rollBack(): bool
public function rollBack(): void
{
throw Exception::notSupported(__METHOD__);
throw NotSupported::new(__METHOD__);
}

/**
Expand All @@ -129,4 +123,9 @@ public function getServerVersion(): string
return '';
}
}

public function getNativeConnection()
{
return $this;
}
}
Loading

0 comments on commit f7d0dda

Please sign in to comment.