Skip to content

Commit f7d0dda

Browse files
authored
Added Doctrine DBAL 4 support (#69)
* Added support for doctrine/dbal ^4.
1 parent 57c4676 commit f7d0dda

19 files changed

+446
-530
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"php": "^8.0",
2929
"ext-pcre": "*",
3030
"ext-mbstring": "*",
31-
"doctrine/dbal": "^3.0",
31+
"doctrine/dbal": "^4.0",
3232
"smi2/phpclickhouse": "^1.0"
3333
},
3434
"require-dev": {

src/ClickHouseConnection.php

+17-18
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@
1818
use ClickHouseDB\Exception\ClickHouseException;
1919
use Doctrine\DBAL\Driver\Connection;
2020
use Doctrine\DBAL\Driver\Result;
21-
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
2221
use Doctrine\DBAL\Driver\Statement;
23-
use Doctrine\DBAL\Exception;
24-
use Doctrine\DBAL\ParameterType;
2522
use Doctrine\DBAL\Platforms\AbstractPlatform;
2623

24+
use Doctrine\DBAL\Platforms\Exception\NotSupported;
2725
use function array_merge;
2826

29-
class ClickHouseConnection implements Connection, ServerInfoAwareConnection
27+
class ClickHouseConnection implements Connection
3028
{
3129
protected Client $client;
3230

@@ -69,13 +67,9 @@ public function query(string $sql): Result
6967
/**
7068
* {@inheritDoc}
7169
*/
72-
public function quote($value, $type = ParameterType::STRING)
70+
public function quote(string $value): string
7371
{
74-
if ($type === ParameterType::STRING) {
75-
return $this->platform->quoteStringLiteral($value);
76-
}
77-
78-
return $value;
72+
return $this->platform->quoteStringLiteral($value);
7973
}
8074

8175
/**
@@ -89,33 +83,33 @@ public function exec(string $sql): int
8983
/**
9084
* {@inheritDoc}
9185
*/
92-
public function lastInsertId($name = null)
86+
public function lastInsertId(): int|string
9387
{
94-
throw Exception::notSupported(__METHOD__);
88+
throw NotSupported::new(__METHOD__);
9589
}
9690

9791
/**
9892
* {@inheritDoc}
9993
*/
100-
public function beginTransaction(): bool
94+
public function beginTransaction(): void
10195
{
102-
throw Exception::notSupported(__METHOD__);
96+
throw NotSupported::new(__METHOD__);
10397
}
10498

10599
/**
106100
* {@inheritDoc}
107101
*/
108-
public function commit(): bool
102+
public function commit(): void
109103
{
110-
throw Exception::notSupported(__METHOD__);
104+
throw NotSupported::new(__METHOD__);
111105
}
112106

113107
/**
114108
* {@inheritDoc}
115109
*/
116-
public function rollBack(): bool
110+
public function rollBack(): void
117111
{
118-
throw Exception::notSupported(__METHOD__);
112+
throw NotSupported::new(__METHOD__);
119113
}
120114

121115
/**
@@ -129,4 +123,9 @@ public function getServerVersion(): string
129123
return '';
130124
}
131125
}
126+
127+
public function getNativeConnection()
128+
{
129+
return $this;
130+
}
132131
}

0 commit comments

Comments
 (0)