forked from doctrine/dbal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConnection.php
102 lines (87 loc) · 2.35 KB
/
Connection.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
namespace Doctrine\DBAL\Portability;
use Doctrine\DBAL\Driver\Connection as ConnectionInterface;
use Doctrine\DBAL\Driver\Result as DriverResult;
use Doctrine\DBAL\Driver\Statement as DriverStatement;
use Doctrine\DBAL\ParameterType;
use Doctrine\Deprecations\Deprecation;
/**
* Portability wrapper for a Connection.
*/
final class Connection implements ConnectionInterface
{
public const PORTABILITY_ALL = 255;
public const PORTABILITY_NONE = 0;
public const PORTABILITY_RTRIM = 1;
public const PORTABILITY_EMPTY_TO_NULL = 4;
public const PORTABILITY_FIX_CASE = 8;
/** @var ConnectionInterface */
private $connection;
/** @var Converter */
private $converter;
public function __construct(ConnectionInterface $connection, Converter $converter)
{
$this->connection = $connection;
$this->converter = $converter;
}
public function prepare(string $sql): DriverStatement
{
return new Statement(
$this->connection->prepare($sql),
$this->converter
);
}
public function query(string $sql): DriverResult
{
return new Result(
$this->connection->query($sql),
$this->converter
);
}
/**
* {@inheritDoc}
*/
public function quote($value, $type = ParameterType::STRING)
{
return $this->connection->quote($value, $type);
}
public function exec(string $sql): int
{
return $this->connection->exec($sql);
}
/**
* {@inheritDoc}
*/
public function lastInsertId($name = null)
{
if ($name !== null) {
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4687',
'The usage of Connection::lastInsertId() with a sequence name is deprecated.'
);
}
return $this->connection->lastInsertId($name);
}
/**
* {@inheritDoc}
*/
public function beginTransaction()
{
return $this->connection->beginTransaction();
}
/**
* {@inheritDoc}
*/
public function commit()
{
return $this->connection->commit();
}
/**
* {@inheritDoc}
*/
public function rollBack()
{
return $this->connection->rollBack();
}
}