|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace DH\Auditor\Provider\Doctrine\Auditing\Logger\Middleware; |
|
6
|
|
|
|
|
7
|
|
|
use Doctrine\DBAL\Driver\Connection as ConnectionInterface; |
|
8
|
|
|
use Doctrine\DBAL\Driver\Result; |
|
9
|
|
|
use Doctrine\DBAL\Driver\Statement; |
|
10
|
|
|
use Doctrine\DBAL\ParameterType; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @interal |
|
14
|
|
|
*/ |
|
15
|
|
|
final class DHConnection implements ConnectionInterface |
|
16
|
|
|
{ |
|
17
|
|
|
private ConnectionInterface $connection; |
|
18
|
|
|
private DHDriver $DHDriver; |
|
19
|
|
|
|
|
20
|
|
|
public function __construct(ConnectionInterface $connection, DHDriver $DHDriver) |
|
21
|
|
|
{ |
|
22
|
|
|
$this->connection = $connection; |
|
23
|
|
|
$this->DHDriver = $DHDriver; |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function prepare(string $sql): Statement |
|
27
|
|
|
{ |
|
28
|
|
|
return $this->connection->prepare($sql); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function query(string $sql): Result |
|
32
|
|
|
{ |
|
33
|
|
|
return $this->connection->query($sql); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function quote($value, $type = ParameterType::STRING) |
|
37
|
|
|
{ |
|
38
|
|
|
return $this->connection->quote($value, $type); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function exec(string $sql): int |
|
42
|
|
|
{ |
|
43
|
|
|
return $this->connection->exec($sql); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function lastInsertId($name = null) |
|
47
|
|
|
{ |
|
48
|
|
|
return $this->connection->lastInsertId($name); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function beginTransaction(): bool |
|
52
|
|
|
{ |
|
53
|
|
|
return $this->connection->beginTransaction(); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function commit(): bool |
|
57
|
|
|
{ |
|
58
|
|
|
$flusherList = $this->DHDriver->getFlusherList(); |
|
59
|
|
|
foreach ($flusherList as $flusher) { |
|
60
|
|
|
($flusher)(); |
|
61
|
|
|
} |
|
62
|
|
|
$this->DHDriver->resetDHFlusherList(); |
|
63
|
|
|
|
|
64
|
|
|
return $this->connection->commit(); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function rollBack(): bool |
|
68
|
|
|
{ |
|
69
|
|
|
$this->DHDriver->resetDHFlusherList(); |
|
70
|
|
|
|
|
71
|
|
|
return $this->connection->rollBack(); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @return object|resource |
|
76
|
|
|
*/ |
|
77
|
|
|
public function getNativeConnection() |
|
78
|
|
|
{ |
|
79
|
|
|
return $this->connection->getNativeConnection(); |
|
|
|
|
|
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|