Skip to content

Commit

Permalink
Merge pull request #27 from zkelo/client_options
Browse files Browse the repository at this point in the history
Add ability to pass options to clickhouse DB client constructor
  • Loading branch information
sartor authored Apr 15, 2021
2 parents d7689e9 + 96d9419 commit 4d6a942
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ class Connection extends \yii\db\Connection
*/
public $commandClass = 'bashkarev\clickhouse\Command';

/**
* Additional options you can pass to clickhouse client constructor
*
* @var array
*/
public $clientOptions = [];

/**
* @var Client
*/
Expand Down Expand Up @@ -55,12 +62,12 @@ public function open()
if ($this->_client === null) {
$config = $this->parseDsn();

$this->_client = new Client([
$this->_client = new Client(array_merge([
'host' => $config['host'] ?? '127.0.0.1',
'port' => $config['port'] ?? 8123,
'username' => $this->username,
'password' => $this->password,
],
], $this->clientOptions),
array_merge([
'database' => $config['database'] ?? 'default',
], $this->attributes ?? [])
Expand Down

0 comments on commit 4d6a942

Please sign in to comment.