Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Doctrine\DBAL\Driver\Middleware;
4
 
5
use Doctrine\DBAL\Driver\Connection;
6
use Doctrine\DBAL\Driver\Result;
7
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
8
use Doctrine\DBAL\Driver\Statement;
9
use Doctrine\DBAL\ParameterType;
10
use Doctrine\Deprecations\Deprecation;
11
use LogicException;
12
 
13
use function get_class;
14
use function method_exists;
15
use function sprintf;
16
 
17
abstract class AbstractConnectionMiddleware implements ServerInfoAwareConnection
18
{
19
    private Connection $wrappedConnection;
20
 
21
    public function __construct(Connection $wrappedConnection)
22
    {
23
        $this->wrappedConnection = $wrappedConnection;
24
    }
25
 
26
    public function prepare(string $sql): Statement
27
    {
28
        return $this->wrappedConnection->prepare($sql);
29
    }
30
 
31
    public function query(string $sql): Result
32
    {
33
        return $this->wrappedConnection->query($sql);
34
    }
35
 
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function quote($value, $type = ParameterType::STRING)
40
    {
41
        return $this->wrappedConnection->quote($value, $type);
42
    }
43
 
44
    public function exec(string $sql): int
45
    {
46
        return $this->wrappedConnection->exec($sql);
47
    }
48
 
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function lastInsertId($name = null)
53
    {
54
        if ($name !== null) {
55
            Deprecation::triggerIfCalledFromOutside(
56
                'doctrine/dbal',
57
                'https://github.com/doctrine/dbal/issues/4687',
58
                'The usage of Connection::lastInsertId() with a sequence name is deprecated.',
59
            );
60
        }
61
 
62
        return $this->wrappedConnection->lastInsertId($name);
63
    }
64
 
65
    /**
66
     * {@inheritdoc}
67
     */
68
    public function beginTransaction()
69
    {
70
        return $this->wrappedConnection->beginTransaction();
71
    }
72
 
73
    /**
74
     * {@inheritdoc}
75
     */
76
    public function commit()
77
    {
78
        return $this->wrappedConnection->commit();
79
    }
80
 
81
    /**
82
     * {@inheritdoc}
83
     */
84
    public function rollBack()
85
    {
86
        return $this->wrappedConnection->rollBack();
87
    }
88
 
89
    /**
90
     * {@inheritdoc}
91
     */
92
    public function getServerVersion()
93
    {
94
        if (! $this->wrappedConnection instanceof ServerInfoAwareConnection) {
95
            throw new LogicException('The underlying connection is not a ServerInfoAwareConnection');
96
        }
97
 
98
        return $this->wrappedConnection->getServerVersion();
99
    }
100
 
101
    /** @return resource|object */
102
    public function getNativeConnection()
103
    {
104
        if (! method_exists($this->wrappedConnection, 'getNativeConnection')) {
105
            throw new LogicException(sprintf(
106
                'The driver connection %s does not support accessing the native connection.',
107
                get_class($this->wrappedConnection),
108
            ));
109
        }
110
 
111
        return $this->wrappedConnection->getNativeConnection();
112
    }
113
}