Skip to content

Commit 4d6a942

Browse files
authored
Merge pull request #27 from zkelo/client_options
Add ability to pass options to clickhouse DB client constructor
2 parents d7689e9 + 96d9419 commit 4d6a942

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Connection.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ class Connection extends \yii\db\Connection
2424
*/
2525
public $commandClass = 'bashkarev\clickhouse\Command';
2626

27+
/**
28+
* Additional options you can pass to clickhouse client constructor
29+
*
30+
* @var array
31+
*/
32+
public $clientOptions = [];
33+
2734
/**
2835
* @var Client
2936
*/
@@ -55,12 +62,12 @@ public function open()
5562
if ($this->_client === null) {
5663
$config = $this->parseDsn();
5764

58-
$this->_client = new Client([
65+
$this->_client = new Client(array_merge([
5966
'host' => $config['host'] ?? '127.0.0.1',
6067
'port' => $config['port'] ?? 8123,
6168
'username' => $this->username,
6269
'password' => $this->password,
63-
],
70+
], $this->clientOptions),
6471
array_merge([
6572
'database' => $config['database'] ?? 'default',
6673
], $this->attributes ?? [])

0 commit comments

Comments
 (0)