Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 148 | Zur aktuellen Revision | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 148 Revision 621
Zeile 19... Zeile 19...
19
use Doctrine\DBAL\Exception\InvalidArgumentException;
19
use Doctrine\DBAL\Exception\InvalidArgumentException;
20
use Doctrine\DBAL\Platforms\AbstractPlatform;
20
use Doctrine\DBAL\Platforms\AbstractPlatform;
21
use Doctrine\DBAL\Query\Expression\ExpressionBuilder;
21
use Doctrine\DBAL\Query\Expression\ExpressionBuilder;
22
use Doctrine\DBAL\Query\QueryBuilder;
22
use Doctrine\DBAL\Query\QueryBuilder;
23
use Doctrine\DBAL\Schema\AbstractSchemaManager;
23
use Doctrine\DBAL\Schema\AbstractSchemaManager;
-
 
24
use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory;
-
 
25
use Doctrine\DBAL\Schema\LegacySchemaManagerFactory;
-
 
26
use Doctrine\DBAL\Schema\SchemaManagerFactory;
24
use Doctrine\DBAL\SQL\Parser;
27
use Doctrine\DBAL\SQL\Parser;
25
use Doctrine\DBAL\Types\Type;
28
use Doctrine\DBAL\Types\Type;
26
use Doctrine\Deprecations\Deprecation;
29
use Doctrine\Deprecations\Deprecation;
27
use LogicException;
30
use LogicException;
-
 
31
use SensitiveParameter;
28
use Throwable;
32
use Throwable;
29
use Traversable;
33
use Traversable;
Zeile 30... Zeile 34...
30
 
34
 
31
use function array_key_exists;
35
use function array_key_exists;
Zeile 48... Zeile 52...
48
 */
52
 */
49
class Connection
53
class Connection
50
{
54
{
51
    /**
55
    /**
52
     * Represents an array of ints to be expanded by Doctrine SQL parsing.
56
     * Represents an array of ints to be expanded by Doctrine SQL parsing.
-
 
57
     *
-
 
58
     * @deprecated Use {@see ArrayParameterType::INTEGER} instead.
53
     */
59
     */
54
    public const PARAM_INT_ARRAY = ParameterType::INTEGER + self::ARRAY_PARAM_OFFSET;
60
    public const PARAM_INT_ARRAY = ArrayParameterType::INTEGER;
Zeile 55... Zeile 61...
55
 
61
 
56
    /**
62
    /**
-
 
63
     * Represents an array of strings to be expanded by Doctrine SQL parsing.
-
 
64
     *
57
     * Represents an array of strings to be expanded by Doctrine SQL parsing.
65
     * @deprecated Use {@see ArrayParameterType::STRING} instead.
58
     */
66
     */
Zeile 59... Zeile 67...
59
    public const PARAM_STR_ARRAY = ParameterType::STRING + self::ARRAY_PARAM_OFFSET;
67
    public const PARAM_STR_ARRAY = ArrayParameterType::STRING;
60
 
68
 
-
 
69
    /**
-
 
70
     * Represents an array of ascii strings to be expanded by Doctrine SQL parsing.
61
    /**
71
     *
62
     * Represents an array of ascii strings to be expanded by Doctrine SQL parsing.
72
     * @deprecated Use {@see ArrayParameterType::ASCII} instead.
Zeile 63... Zeile 73...
63
     */
73
     */
64
    public const PARAM_ASCII_STR_ARRAY = ParameterType::ASCII + self::ARRAY_PARAM_OFFSET;
74
    public const PARAM_ASCII_STR_ARRAY = ArrayParameterType::ASCII;
65
 
75
 
66
    /**
76
    /**
Zeile 71... Zeile 81...
71
    public const ARRAY_PARAM_OFFSET = 100;
81
    public const ARRAY_PARAM_OFFSET = 100;
Zeile 72... Zeile 82...
72
 
82
 
73
    /**
83
    /**
74
     * The wrapped driver connection.
84
     * The wrapped driver connection.
75
     *
85
     *
76
     * @var \Doctrine\DBAL\Driver\Connection|null
86
     * @var DriverConnection|null
77
     */
87
     */
Zeile 78... Zeile 88...
78
    protected $_conn;
88
    protected $_conn;
79
 
89
 
Zeile 151... Zeile 161...
151
    /**
161
    /**
152
     * Flag that indicates whether the current transaction is marked for rollback only.
162
     * Flag that indicates whether the current transaction is marked for rollback only.
153
     */
163
     */
154
    private bool $isRollbackOnly = false;
164
    private bool $isRollbackOnly = false;
Zeile -... Zeile 165...
-
 
165
 
-
 
166
    private SchemaManagerFactory $schemaManagerFactory;
155
 
167
 
156
    /**
168
    /**
157
     * Initializes a new instance of the Connection class.
169
     * Initializes a new instance of the Connection class.
158
     *
170
     *
159
     * @internal The connection can be only instantiated by the driver manager.
171
     * @internal The connection can be only instantiated by the driver manager.
Zeile 165... Zeile 177...
165
     * @psalm-param Params $params
177
     * @psalm-param Params $params
166
     *
178
     *
167
     * @throws Exception
179
     * @throws Exception
168
     */
180
     */
169
    public function __construct(
181
    public function __construct(
-
 
182
        #[SensitiveParameter]
170
        array $params,
183
        array $params,
171
        Driver $driver,
184
        Driver $driver,
172
        ?Configuration $config = null,
185
        ?Configuration $config = null,
173
        ?EventManager $eventManager = null
186
        ?EventManager $eventManager = null
174
    ) {
187
    ) {
Zeile 199... Zeile 212...
199
        }
212
        }
Zeile 200... Zeile 213...
200
 
213
 
Zeile 201... Zeile 214...
201
        $this->_expr = $this->createExpressionBuilder();
214
        $this->_expr = $this->createExpressionBuilder();
-
 
215
 
-
 
216
        $this->autoCommit = $config->getAutoCommit();
-
 
217
 
-
 
218
        $schemaManagerFactory = $config->getSchemaManagerFactory();
-
 
219
        if ($schemaManagerFactory === null) {
-
 
220
            Deprecation::trigger(
-
 
221
                'doctrine/dbal',
-
 
222
                'https://github.com/doctrine/dbal/issues/5812',
-
 
223
                'Not configuring a schema manager factory is deprecated.'
-
 
224
                    . ' Use %s which is going to be the default in DBAL 4.',
-
 
225
                DefaultSchemaManagerFactory::class,
-
 
226
            );
-
 
227
 
-
 
228
            $schemaManagerFactory = new LegacySchemaManagerFactory();
-
 
229
        }
202
 
230
 
Zeile 203... Zeile 231...
203
        $this->autoCommit = $config->getAutoCommit();
231
        $this->schemaManagerFactory = $schemaManagerFactory;
204
    }
232
    }
205
 
233
 
Zeile 326... Zeile 354...
326
     *
354
     *
327
     * @return bool TRUE if the connection was successfully established, FALSE if
355
     * @return bool TRUE if the connection was successfully established, FALSE if
328
     *              the connection is already open.
356
     *              the connection is already open.
329
     *
357
     *
330
     * @throws Exception
358
     * @throws Exception
-
 
359
     *
-
 
360
     * @psalm-assert !null $this->_conn
331
     */
361
     */
332
    public function connect()
362
    public function connect()
333
    {
363
    {
334
        Deprecation::triggerIfCalledFromOutside(
364
        Deprecation::triggerIfCalledFromOutside(
335
            'doctrine/dbal',
365
            'doctrine/dbal',
Zeile 1091... Zeile 1121...
1091
        if ($resultCache === null) {
1121
        if ($resultCache === null) {
1092
            throw CacheException::noResultDriverConfigured();
1122
            throw CacheException::noResultDriverConfigured();
1093
        }
1123
        }
Zeile 1094... Zeile 1124...
1094
 
1124
 
1095
        $connectionParams = $this->params;
1125
        $connectionParams = $this->params;
Zeile 1096... Zeile 1126...
1096
        unset($connectionParams['platform']);
1126
        unset($connectionParams['platform'], $connectionParams['password'], $connectionParams['url']);
Zeile 1097... Zeile 1127...
1097
 
1127
 
Zeile 1615... Zeile 1645...
1615
                . ' Use Connection::getNativeConnection() to access the native connection.',
1645
                . ' Use Connection::getNativeConnection() to access the native connection.',
1616
        );
1646
        );
Zeile 1617... Zeile 1647...
1617
 
1647
 
Zeile 1618... Zeile -...
1618
        $this->connect();
-
 
1619
 
-
 
1620
        assert($this->_conn !== null);
1648
        $this->connect();
1621
 
1649
 
Zeile 1622... Zeile 1650...
1622
        return $this->_conn;
1650
        return $this->_conn;
1623
    }
1651
    }
1624
 
1652
 
1625
    /** @return resource|object */
1653
    /** @return resource|object */
Zeile 1626... Zeile -...
1626
    public function getNativeConnection()
-
 
1627
    {
1654
    public function getNativeConnection()
1628
        $this->connect();
1655
    {
1629
 
1656
        $this->connect();
1630
        assert($this->_conn !== null);
1657
 
1631
        if (! method_exists($this->_conn, 'getNativeConnection')) {
1658
        if (! method_exists($this->_conn, 'getNativeConnection')) {
Zeile 1644... Zeile 1671...
1644
     *
1671
     *
1645
     * @throws Exception
1672
     * @throws Exception
1646
     */
1673
     */
1647
    public function createSchemaManager(): AbstractSchemaManager
1674
    public function createSchemaManager(): AbstractSchemaManager
1648
    {
1675
    {
1649
        return $this->_driver->getSchemaManager(
1676
        return $this->schemaManagerFactory->createSchemaManager($this);
1650
            $this,
-
 
1651
            $this->getDatabasePlatform(),
-
 
1652
        );
-
 
1653
    }
1677
    }
Zeile 1654... Zeile 1678...
1654
 
1678
 
1655
    /**
1679
    /**
1656
     * Gets the SchemaManager that can be used to inspect or change the
1680
     * Gets the SchemaManager that can be used to inspect or change the
Zeile 1886... Zeile 1910...
1886
            return true;
1910
            return true;
1887
        }
1911
        }
Zeile 1888... Zeile 1912...
1888
 
1912
 
1889
        foreach ($types as $type) {
1913
        foreach ($types as $type) {
1890
            if (
1914
            if (
1891
                $type === self::PARAM_INT_ARRAY
1915
                $type === ArrayParameterType::INTEGER
1892
                || $type === self::PARAM_STR_ARRAY
1916
                || $type === ArrayParameterType::STRING
1893
                || $type === self::PARAM_ASCII_STR_ARRAY
1917
                || $type === ArrayParameterType::ASCII
1894
            ) {
1918
            ) {
1895
                return true;
1919
                return true;
1896
            }
1920
            }