1
1
<?php
2
+
3
+ declare (strict_types=1 );
4
+
2
5
/*
3
6
* This file is part of the FODDBALClickHouse package -- Doctrine DBAL library
4
7
* for ClickHouse (a column-oriented DBMS for OLAP <https://clickhouse.yandex/>)
12
15
namespace FOD \DBALClickHouse ;
13
16
14
17
use ClickHouseDB \Client as Smi2CHClient ;
18
+ use Doctrine \DBAL \Driver \Connection ;
15
19
use Doctrine \DBAL \ParameterType ;
16
20
use Doctrine \DBAL \Platforms \AbstractPlatform ;
17
21
18
22
/**
19
23
* ClickHouse implementation for the Connection interface.
20
- *
21
- * @author Mochalygin <[email protected] >
22
24
*/
23
- class ClickHouseConnection implements \ Doctrine \ DBAL \ Driver \ Connection
25
+ class ClickHouseConnection implements Connection
24
26
{
25
- /**
26
- * @var Smi2CHClient
27
- */
27
+ /** @var Smi2CHClient */
28
28
protected $ smi2CHClient ;
29
29
30
- /**
31
- * @var AbstractPlatform
32
- */
30
+ /** @var AbstractPlatform */
33
31
protected $ platform ;
34
32
35
33
/**
36
34
* Connection constructor
37
35
*
38
- * @param array $params
39
- * @param string $username The username to use when connecting.
40
- * @param string $password The password to use when connecting.
41
- * @param AbstractPlatform $platform
36
+ * @param array $params Array with connection params.
42
37
*/
43
38
public function __construct (
44
39
array $ params ,
45
- $ username ,
46
- $ password ,
40
+ string $ username ,
41
+ string $ password ,
47
42
AbstractPlatform $ platform
48
43
) {
49
44
$ this ->smi2CHClient = new Smi2CHClient ([
@@ -64,10 +59,6 @@ public function __construct(
64
59
*/
65
60
public function prepare ($ prepareString )
66
61
{
67
- if (!$ this ->smi2CHClient ) {
68
- throw new \Exception ('ClickHouse\Client was not initialized ' );
69
- }
70
-
71
62
return new ClickHouseStatement ($ this ->smi2CHClient , $ prepareString , $ this ->platform );
72
63
}
73
64
@@ -88,7 +79,7 @@ public function query()
88
79
*/
89
80
public function quote ($ input , $ type = ParameterType::STRING )
90
81
{
91
- if (ParameterType:: INTEGER === $ type ) {
82
+ if ($ type === ParameterType:: INTEGER ) {
92
83
return $ input ;
93
84
}
94
85
@@ -98,7 +89,7 @@ public function quote($input, $type = ParameterType::STRING)
98
89
/**
99
90
* {@inheritDoc}
100
91
*/
101
- public function exec ($ statement )
92
+ public function exec ($ statement ) : int
102
93
{
103
94
$ stmt = $ this ->prepare ($ statement );
104
95
$ stmt ->execute ();
0 commit comments