From bf6655a534a6775d30cafa67bd801276bda1d98d Mon Sep 17 00:00:00 2001 From: polo Date: Tue, 13 Aug 2024 23:45:21 +0200 Subject: =?UTF-8?q?VERSION=200.2=20doctrine=20ORM=20et=20entit=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dbal/src/Driver/API/ExceptionConverter.php | 25 +++ .../src/Driver/API/IBMDB2/ExceptionConverter.php | 47 ++++ .../src/Driver/API/MySQL/ExceptionConverter.php | 94 ++++++++ .../dbal/src/Driver/API/OCI/ExceptionConverter.php | 52 +++++ .../Driver/API/PostgreSQL/ExceptionConverter.php | 82 +++++++ .../src/Driver/API/SQLSrv/ExceptionConverter.php | 49 +++++ .../src/Driver/API/SQLite/ExceptionConverter.php | 85 ++++++++ .../doctrine/dbal/src/Driver/AbstractDB2Driver.php | 27 +++ .../doctrine/dbal/src/Driver/AbstractException.php | 36 ++++ .../dbal/src/Driver/AbstractMySQLDriver.php | 86 ++++++++ .../dbal/src/Driver/AbstractOracleDriver.php | 38 ++++ .../AbstractOracleDriver/EasyConnectString.php | 112 ++++++++++ .../dbal/src/Driver/AbstractPostgreSQLDriver.php | 27 +++ .../dbal/src/Driver/AbstractSQLServerDriver.php | 27 +++ .../Exception/PortWithoutHost.php | 20 ++ .../dbal/src/Driver/AbstractSQLiteDriver.php | 27 +++ .../Middleware/EnableForeignKeys.php | 33 +++ vendor/doctrine/dbal/src/Driver/Connection.php | 93 ++++++++ vendor/doctrine/dbal/src/Driver/Exception.php | 25 +++ .../Exception/IdentityColumnsNotSupported.php | 21 ++ .../dbal/src/Driver/Exception/NoIdentityValue.php | 21 ++ vendor/doctrine/dbal/src/Driver/FetchUtils.php | 69 ++++++ .../doctrine/dbal/src/Driver/IBMDB2/Connection.php | 131 +++++++++++ .../dbal/src/Driver/IBMDB2/DataSourceName.php | 80 +++++++ vendor/doctrine/dbal/src/Driver/IBMDB2/Driver.php | 41 ++++ .../IBMDB2/Exception/CannotCopyStreamToStream.php | 27 +++ .../IBMDB2/Exception/CannotCreateTemporaryFile.php | 27 +++ .../Driver/IBMDB2/Exception/ConnectionError.php | 29 +++ .../Driver/IBMDB2/Exception/ConnectionFailed.php | 28 +++ .../dbal/src/Driver/IBMDB2/Exception/Factory.php | 35 +++ .../src/Driver/IBMDB2/Exception/PrepareFailed.php | 25 +++ .../src/Driver/IBMDB2/Exception/StatementError.php | 34 +++ vendor/doctrine/dbal/src/Driver/IBMDB2/Result.php | 106 +++++++++ .../doctrine/dbal/src/Driver/IBMDB2/Statement.php | 156 ++++++++++++++ vendor/doctrine/dbal/src/Driver/Middleware.php | 12 ++ .../Middleware/AbstractConnectionMiddleware.php | 69 ++++++ .../Driver/Middleware/AbstractDriverMiddleware.php | 39 ++++ .../Driver/Middleware/AbstractResultMiddleware.php | 68 ++++++ .../Middleware/AbstractStatementMiddleware.php | 26 +++ .../doctrine/dbal/src/Driver/Mysqli/Connection.php | 112 ++++++++++ vendor/doctrine/dbal/src/Driver/Mysqli/Driver.php | 117 ++++++++++ .../Driver/Mysqli/Exception/ConnectionError.php | 30 +++ .../Driver/Mysqli/Exception/ConnectionFailed.php | 35 +++ .../Mysqli/Exception/FailedReadingStreamOffset.php | 22 ++ .../src/Driver/Mysqli/Exception/HostRequired.php | 20 ++ .../src/Driver/Mysqli/Exception/InvalidCharset.php | 41 ++++ .../src/Driver/Mysqli/Exception/InvalidOption.php | 24 +++ .../NonStreamResourceUsedAsLargeObject.php | 24 +++ .../src/Driver/Mysqli/Exception/StatementError.php | 30 +++ .../dbal/src/Driver/Mysqli/Initializer.php | 14 ++ .../dbal/src/Driver/Mysqli/Initializer/Charset.php | 32 +++ .../dbal/src/Driver/Mysqli/Initializer/Options.php | 28 +++ .../dbal/src/Driver/Mysqli/Initializer/Secure.php | 27 +++ vendor/doctrine/dbal/src/Driver/Mysqli/Result.php | 164 ++++++++++++++ .../doctrine/dbal/src/Driver/Mysqli/Statement.php | 154 +++++++++++++ .../doctrine/dbal/src/Driver/OCI8/Connection.php | 119 ++++++++++ .../OCI8/ConvertPositionalToNamedPlaceholders.php | 58 +++++ vendor/doctrine/dbal/src/Driver/OCI8/Driver.php | 60 ++++++ .../src/Driver/OCI8/Exception/ConnectionFailed.php | 26 +++ .../dbal/src/Driver/OCI8/Exception/Error.php | 27 +++ .../Driver/OCI8/Exception/InvalidConfiguration.php | 20 ++ .../OCI8/Exception/NonTerminatedStringLiteral.php | 27 +++ .../OCI8/Exception/UnknownParameterIndex.php | 24 +++ .../dbal/src/Driver/OCI8/ExecutionMode.php | 30 +++ .../Driver/OCI8/Middleware/InitializeSession.php | 40 ++++ vendor/doctrine/dbal/src/Driver/OCI8/Result.php | 128 +++++++++++ vendor/doctrine/dbal/src/Driver/OCI8/Statement.php | 103 +++++++++ vendor/doctrine/dbal/src/Driver/PDO/Connection.php | 133 ++++++++++++ vendor/doctrine/dbal/src/Driver/PDO/Exception.php | 30 +++ .../doctrine/dbal/src/Driver/PDO/MySQL/Driver.php | 76 +++++++ vendor/doctrine/dbal/src/Driver/PDO/OCI/Driver.php | 61 ++++++ .../doctrine/dbal/src/Driver/PDO/PgSQL/Driver.php | 113 ++++++++++ vendor/doctrine/dbal/src/Driver/PDO/Result.php | 110 ++++++++++ .../dbal/src/Driver/PDO/SQLSrv/Connection.php | 29 +++ .../doctrine/dbal/src/Driver/PDO/SQLSrv/Driver.php | 108 ++++++++++ .../dbal/src/Driver/PDO/SQLSrv/Statement.php | 46 ++++ .../doctrine/dbal/src/Driver/PDO/SQLite/Driver.php | 55 +++++ vendor/doctrine/dbal/src/Driver/PDO/Statement.php | 80 +++++++ .../doctrine/dbal/src/Driver/PgSQL/Connection.php | 129 +++++++++++ .../dbal/src/Driver/PgSQL/ConvertParameters.php | 49 +++++ vendor/doctrine/dbal/src/Driver/PgSQL/Driver.php | 88 ++++++++ .../doctrine/dbal/src/Driver/PgSQL/Exception.php | 31 +++ .../src/Driver/PgSQL/Exception/UnexpectedValue.php | 29 +++ .../Driver/PgSQL/Exception/UnknownParameter.php | 20 ++ vendor/doctrine/dbal/src/Driver/PgSQL/Result.php | 240 +++++++++++++++++++++ .../doctrine/dbal/src/Driver/PgSQL/Statement.php | 91 ++++++++ vendor/doctrine/dbal/src/Driver/Result.php | 93 ++++++++ .../doctrine/dbal/src/Driver/SQLSrv/Connection.php | 108 ++++++++++ vendor/doctrine/dbal/src/Driver/SQLSrv/Driver.php | 73 +++++++ .../dbal/src/Driver/SQLSrv/Exception/Error.php | 44 ++++ vendor/doctrine/dbal/src/Driver/SQLSrv/Result.php | 104 +++++++++ .../doctrine/dbal/src/Driver/SQLSrv/Statement.php | 140 ++++++++++++ .../dbal/src/Driver/SQLite3/Connection.php | 109 ++++++++++ vendor/doctrine/dbal/src/Driver/SQLite3/Driver.php | 48 +++++ .../doctrine/dbal/src/Driver/SQLite3/Exception.php | 20 ++ vendor/doctrine/dbal/src/Driver/SQLite3/Result.php | 88 ++++++++ .../doctrine/dbal/src/Driver/SQLite3/Statement.php | 61 ++++++ vendor/doctrine/dbal/src/Driver/Statement.php | 39 ++++ 98 files changed, 6010 insertions(+) create mode 100644 vendor/doctrine/dbal/src/Driver/API/ExceptionConverter.php create mode 100644 vendor/doctrine/dbal/src/Driver/API/IBMDB2/ExceptionConverter.php create mode 100644 vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php create mode 100644 vendor/doctrine/dbal/src/Driver/API/OCI/ExceptionConverter.php create mode 100644 vendor/doctrine/dbal/src/Driver/API/PostgreSQL/ExceptionConverter.php create mode 100644 vendor/doctrine/dbal/src/Driver/API/SQLSrv/ExceptionConverter.php create mode 100644 vendor/doctrine/dbal/src/Driver/API/SQLite/ExceptionConverter.php create mode 100644 vendor/doctrine/dbal/src/Driver/AbstractDB2Driver.php create mode 100644 vendor/doctrine/dbal/src/Driver/AbstractException.php create mode 100644 vendor/doctrine/dbal/src/Driver/AbstractMySQLDriver.php create mode 100644 vendor/doctrine/dbal/src/Driver/AbstractOracleDriver.php create mode 100644 vendor/doctrine/dbal/src/Driver/AbstractOracleDriver/EasyConnectString.php create mode 100644 vendor/doctrine/dbal/src/Driver/AbstractPostgreSQLDriver.php create mode 100644 vendor/doctrine/dbal/src/Driver/AbstractSQLServerDriver.php create mode 100644 vendor/doctrine/dbal/src/Driver/AbstractSQLServerDriver/Exception/PortWithoutHost.php create mode 100644 vendor/doctrine/dbal/src/Driver/AbstractSQLiteDriver.php create mode 100644 vendor/doctrine/dbal/src/Driver/AbstractSQLiteDriver/Middleware/EnableForeignKeys.php create mode 100644 vendor/doctrine/dbal/src/Driver/Connection.php create mode 100644 vendor/doctrine/dbal/src/Driver/Exception.php create mode 100644 vendor/doctrine/dbal/src/Driver/Exception/IdentityColumnsNotSupported.php create mode 100644 vendor/doctrine/dbal/src/Driver/Exception/NoIdentityValue.php create mode 100644 vendor/doctrine/dbal/src/Driver/FetchUtils.php create mode 100644 vendor/doctrine/dbal/src/Driver/IBMDB2/Connection.php create mode 100644 vendor/doctrine/dbal/src/Driver/IBMDB2/DataSourceName.php create mode 100644 vendor/doctrine/dbal/src/Driver/IBMDB2/Driver.php create mode 100644 vendor/doctrine/dbal/src/Driver/IBMDB2/Exception/CannotCopyStreamToStream.php create mode 100644 vendor/doctrine/dbal/src/Driver/IBMDB2/Exception/CannotCreateTemporaryFile.php create mode 100644 vendor/doctrine/dbal/src/Driver/IBMDB2/Exception/ConnectionError.php create mode 100644 vendor/doctrine/dbal/src/Driver/IBMDB2/Exception/ConnectionFailed.php create mode 100644 vendor/doctrine/dbal/src/Driver/IBMDB2/Exception/Factory.php create mode 100644 vendor/doctrine/dbal/src/Driver/IBMDB2/Exception/PrepareFailed.php create mode 100644 vendor/doctrine/dbal/src/Driver/IBMDB2/Exception/StatementError.php create mode 100644 vendor/doctrine/dbal/src/Driver/IBMDB2/Result.php create mode 100644 vendor/doctrine/dbal/src/Driver/IBMDB2/Statement.php create mode 100644 vendor/doctrine/dbal/src/Driver/Middleware.php create mode 100644 vendor/doctrine/dbal/src/Driver/Middleware/AbstractConnectionMiddleware.php create mode 100644 vendor/doctrine/dbal/src/Driver/Middleware/AbstractDriverMiddleware.php create mode 100644 vendor/doctrine/dbal/src/Driver/Middleware/AbstractResultMiddleware.php create mode 100644 vendor/doctrine/dbal/src/Driver/Middleware/AbstractStatementMiddleware.php create mode 100644 vendor/doctrine/dbal/src/Driver/Mysqli/Connection.php create mode 100644 vendor/doctrine/dbal/src/Driver/Mysqli/Driver.php create mode 100644 vendor/doctrine/dbal/src/Driver/Mysqli/Exception/ConnectionError.php create mode 100644 vendor/doctrine/dbal/src/Driver/Mysqli/Exception/ConnectionFailed.php create mode 100644 vendor/doctrine/dbal/src/Driver/Mysqli/Exception/FailedReadingStreamOffset.php create mode 100644 vendor/doctrine/dbal/src/Driver/Mysqli/Exception/HostRequired.php create mode 100644 vendor/doctrine/dbal/src/Driver/Mysqli/Exception/InvalidCharset.php create mode 100644 vendor/doctrine/dbal/src/Driver/Mysqli/Exception/InvalidOption.php create mode 100644 vendor/doctrine/dbal/src/Driver/Mysqli/Exception/NonStreamResourceUsedAsLargeObject.php create mode 100644 vendor/doctrine/dbal/src/Driver/Mysqli/Exception/StatementError.php create mode 100644 vendor/doctrine/dbal/src/Driver/Mysqli/Initializer.php create mode 100644 vendor/doctrine/dbal/src/Driver/Mysqli/Initializer/Charset.php create mode 100644 vendor/doctrine/dbal/src/Driver/Mysqli/Initializer/Options.php create mode 100644 vendor/doctrine/dbal/src/Driver/Mysqli/Initializer/Secure.php create mode 100644 vendor/doctrine/dbal/src/Driver/Mysqli/Result.php create mode 100644 vendor/doctrine/dbal/src/Driver/Mysqli/Statement.php create mode 100644 vendor/doctrine/dbal/src/Driver/OCI8/Connection.php create mode 100644 vendor/doctrine/dbal/src/Driver/OCI8/ConvertPositionalToNamedPlaceholders.php create mode 100644 vendor/doctrine/dbal/src/Driver/OCI8/Driver.php create mode 100644 vendor/doctrine/dbal/src/Driver/OCI8/Exception/ConnectionFailed.php create mode 100644 vendor/doctrine/dbal/src/Driver/OCI8/Exception/Error.php create mode 100644 vendor/doctrine/dbal/src/Driver/OCI8/Exception/InvalidConfiguration.php create mode 100644 vendor/doctrine/dbal/src/Driver/OCI8/Exception/NonTerminatedStringLiteral.php create mode 100644 vendor/doctrine/dbal/src/Driver/OCI8/Exception/UnknownParameterIndex.php create mode 100644 vendor/doctrine/dbal/src/Driver/OCI8/ExecutionMode.php create mode 100644 vendor/doctrine/dbal/src/Driver/OCI8/Middleware/InitializeSession.php create mode 100644 vendor/doctrine/dbal/src/Driver/OCI8/Result.php create mode 100644 vendor/doctrine/dbal/src/Driver/OCI8/Statement.php create mode 100644 vendor/doctrine/dbal/src/Driver/PDO/Connection.php create mode 100644 vendor/doctrine/dbal/src/Driver/PDO/Exception.php create mode 100644 vendor/doctrine/dbal/src/Driver/PDO/MySQL/Driver.php create mode 100644 vendor/doctrine/dbal/src/Driver/PDO/OCI/Driver.php create mode 100644 vendor/doctrine/dbal/src/Driver/PDO/PgSQL/Driver.php create mode 100644 vendor/doctrine/dbal/src/Driver/PDO/Result.php create mode 100644 vendor/doctrine/dbal/src/Driver/PDO/SQLSrv/Connection.php create mode 100644 vendor/doctrine/dbal/src/Driver/PDO/SQLSrv/Driver.php create mode 100644 vendor/doctrine/dbal/src/Driver/PDO/SQLSrv/Statement.php create mode 100644 vendor/doctrine/dbal/src/Driver/PDO/SQLite/Driver.php create mode 100644 vendor/doctrine/dbal/src/Driver/PDO/Statement.php create mode 100644 vendor/doctrine/dbal/src/Driver/PgSQL/Connection.php create mode 100644 vendor/doctrine/dbal/src/Driver/PgSQL/ConvertParameters.php create mode 100644 vendor/doctrine/dbal/src/Driver/PgSQL/Driver.php create mode 100644 vendor/doctrine/dbal/src/Driver/PgSQL/Exception.php create mode 100644 vendor/doctrine/dbal/src/Driver/PgSQL/Exception/UnexpectedValue.php create mode 100644 vendor/doctrine/dbal/src/Driver/PgSQL/Exception/UnknownParameter.php create mode 100644 vendor/doctrine/dbal/src/Driver/PgSQL/Result.php create mode 100644 vendor/doctrine/dbal/src/Driver/PgSQL/Statement.php create mode 100644 vendor/doctrine/dbal/src/Driver/Result.php create mode 100644 vendor/doctrine/dbal/src/Driver/SQLSrv/Connection.php create mode 100644 vendor/doctrine/dbal/src/Driver/SQLSrv/Driver.php create mode 100644 vendor/doctrine/dbal/src/Driver/SQLSrv/Exception/Error.php create mode 100644 vendor/doctrine/dbal/src/Driver/SQLSrv/Result.php create mode 100644 vendor/doctrine/dbal/src/Driver/SQLSrv/Statement.php create mode 100644 vendor/doctrine/dbal/src/Driver/SQLite3/Connection.php create mode 100644 vendor/doctrine/dbal/src/Driver/SQLite3/Driver.php create mode 100644 vendor/doctrine/dbal/src/Driver/SQLite3/Exception.php create mode 100644 vendor/doctrine/dbal/src/Driver/SQLite3/Result.php create mode 100644 vendor/doctrine/dbal/src/Driver/SQLite3/Statement.php create mode 100644 vendor/doctrine/dbal/src/Driver/Statement.php (limited to 'vendor/doctrine/dbal/src/Driver') diff --git a/vendor/doctrine/dbal/src/Driver/API/ExceptionConverter.php b/vendor/doctrine/dbal/src/Driver/API/ExceptionConverter.php new file mode 100644 index 0000000..a7bf271 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/API/ExceptionConverter.php @@ -0,0 +1,25 @@ +getCode()) { + -104 => new SyntaxErrorException($exception, $query), + -203 => new NonUniqueFieldNameException($exception, $query), + -204 => new TableNotFoundException($exception, $query), + -206 => new InvalidFieldNameException($exception, $query), + -407 => new NotNullConstraintViolationException($exception, $query), + -530, + -531, + -532, + -20356 => new ForeignKeyConstraintViolationException($exception, $query), + -601 => new TableExistsException($exception, $query), + -803 => new UniqueConstraintViolationException($exception, $query), + -1336, + -30082 => new ConnectionException($exception, $query), + default => new DriverException($exception, $query), + }; + } +} diff --git a/vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php b/vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php new file mode 100644 index 0000000..ad0f0e1 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php @@ -0,0 +1,94 @@ +getCode()) { + 1008 => new DatabaseDoesNotExist($exception, $query), + 1213 => new DeadlockException($exception, $query), + 1205 => new LockWaitTimeoutException($exception, $query), + 1050 => new TableExistsException($exception, $query), + 1051, + 1146 => new TableNotFoundException($exception, $query), + 1216, + 1217, + 1451, + 1452, + 1701 => new ForeignKeyConstraintViolationException($exception, $query), + 1062, + 1557, + 1569, + 1586 => new UniqueConstraintViolationException($exception, $query), + 1054, + 1166, + 1611 => new InvalidFieldNameException($exception, $query), + 1052, + 1060, + 1110 => new NonUniqueFieldNameException($exception, $query), + 1064, + 1149, + 1287, + 1341, + 1342, + 1343, + 1344, + 1382, + 1479, + 1541, + 1554, + 1626 => new SyntaxErrorException($exception, $query), + 1044, + 1045, + 1046, + 1049, + 1095, + 1142, + 1143, + 1227, + 1370, + 1429, + 2002, + 2005, + 2054 => new ConnectionException($exception, $query), + 2006, + 4031 => new ConnectionLost($exception, $query), + 1048, + 1121, + 1138, + 1171, + 1252, + 1263, + 1364, + 1566 => new NotNullConstraintViolationException($exception, $query), + default => new DriverException($exception, $query), + }; + } +} diff --git a/vendor/doctrine/dbal/src/Driver/API/OCI/ExceptionConverter.php b/vendor/doctrine/dbal/src/Driver/API/OCI/ExceptionConverter.php new file mode 100644 index 0000000..1c0dc79 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/API/OCI/ExceptionConverter.php @@ -0,0 +1,52 @@ +getCode()) { + 1, + 2299, + 38911 => new UniqueConstraintViolationException($exception, $query), + 904 => new InvalidFieldNameException($exception, $query), + 918, + 960 => new NonUniqueFieldNameException($exception, $query), + 923 => new SyntaxErrorException($exception, $query), + 942 => new TableNotFoundException($exception, $query), + 955 => new TableExistsException($exception, $query), + 1017, + 12545 => new ConnectionException($exception, $query), + 1400 => new NotNullConstraintViolationException($exception, $query), + 1918 => new DatabaseDoesNotExist($exception, $query), + 2289, + 2443, + 4080 => new DatabaseObjectNotFoundException($exception, $query), + 2266, + 2291, + 2292 => new ForeignKeyConstraintViolationException($exception, $query), + default => new DriverException($exception, $query), + }; + } +} diff --git a/vendor/doctrine/dbal/src/Driver/API/PostgreSQL/ExceptionConverter.php b/vendor/doctrine/dbal/src/Driver/API/PostgreSQL/ExceptionConverter.php new file mode 100644 index 0000000..54e4966 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/API/PostgreSQL/ExceptionConverter.php @@ -0,0 +1,82 @@ +getSQLState()) { + case '40001': + case '40P01': + return new DeadlockException($exception, $query); + + case '0A000': + // Foreign key constraint violations during a TRUNCATE operation + // are considered "feature not supported" in PostgreSQL. + if (str_contains($exception->getMessage(), 'truncate')) { + return new ForeignKeyConstraintViolationException($exception, $query); + } + + break; + + case '23502': + return new NotNullConstraintViolationException($exception, $query); + + case '23503': + return new ForeignKeyConstraintViolationException($exception, $query); + + case '23505': + return new UniqueConstraintViolationException($exception, $query); + + case '3D000': + return new DatabaseDoesNotExist($exception, $query); + + case '3F000': + return new SchemaDoesNotExist($exception, $query); + + case '42601': + return new SyntaxErrorException($exception, $query); + + case '42702': + return new NonUniqueFieldNameException($exception, $query); + + case '42703': + return new InvalidFieldNameException($exception, $query); + + case '42P01': + return new TableNotFoundException($exception, $query); + + case '42P07': + return new TableExistsException($exception, $query); + + case '08006': + return new ConnectionException($exception, $query); + } + + return new DriverException($exception, $query); + } +} diff --git a/vendor/doctrine/dbal/src/Driver/API/SQLSrv/ExceptionConverter.php b/vendor/doctrine/dbal/src/Driver/API/SQLSrv/ExceptionConverter.php new file mode 100644 index 0000000..561e58b --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/API/SQLSrv/ExceptionConverter.php @@ -0,0 +1,49 @@ +getCode()) { + 102 => new SyntaxErrorException($exception, $query), + 207 => new InvalidFieldNameException($exception, $query), + 208 => new TableNotFoundException($exception, $query), + 209 => new NonUniqueFieldNameException($exception, $query), + 515 => new NotNullConstraintViolationException($exception, $query), + 547, + 4712 => new ForeignKeyConstraintViolationException($exception, $query), + 2601, + 2627 => new UniqueConstraintViolationException($exception, $query), + 2714 => new TableExistsException($exception, $query), + 3701, + 15151 => new DatabaseObjectNotFoundException($exception, $query), + 11001, + 18456 => new ConnectionException($exception, $query), + default => new DriverException($exception, $query), + }; + } +} diff --git a/vendor/doctrine/dbal/src/Driver/API/SQLite/ExceptionConverter.php b/vendor/doctrine/dbal/src/Driver/API/SQLite/ExceptionConverter.php new file mode 100644 index 0000000..5885195 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/API/SQLite/ExceptionConverter.php @@ -0,0 +1,85 @@ +getMessage(), 'database is locked')) { + return new LockWaitTimeoutException($exception, $query); + } + + if ( + str_contains($exception->getMessage(), 'must be unique') || + str_contains($exception->getMessage(), 'is not unique') || + str_contains($exception->getMessage(), 'are not unique') || + str_contains($exception->getMessage(), 'UNIQUE constraint failed') + ) { + return new UniqueConstraintViolationException($exception, $query); + } + + if ( + str_contains($exception->getMessage(), 'may not be NULL') || + str_contains($exception->getMessage(), 'NOT NULL constraint failed') + ) { + return new NotNullConstraintViolationException($exception, $query); + } + + if (str_contains($exception->getMessage(), 'no such table:')) { + return new TableNotFoundException($exception, $query); + } + + if (str_contains($exception->getMessage(), 'already exists')) { + return new TableExistsException($exception, $query); + } + + if (str_contains($exception->getMessage(), 'has no column named')) { + return new InvalidFieldNameException($exception, $query); + } + + if (str_contains($exception->getMessage(), 'ambiguous column name')) { + return new NonUniqueFieldNameException($exception, $query); + } + + if (str_contains($exception->getMessage(), 'syntax error')) { + return new SyntaxErrorException($exception, $query); + } + + if (str_contains($exception->getMessage(), 'attempt to write a readonly database')) { + return new ReadOnlyException($exception, $query); + } + + if (str_contains($exception->getMessage(), 'unable to open database file')) { + return new ConnectionException($exception, $query); + } + + if (str_contains($exception->getMessage(), 'FOREIGN KEY constraint failed')) { + return new ForeignKeyConstraintViolationException($exception, $query); + } + + return new DriverException($exception, $query); + } +} diff --git a/vendor/doctrine/dbal/src/Driver/AbstractDB2Driver.php b/vendor/doctrine/dbal/src/Driver/AbstractDB2Driver.php new file mode 100644 index 0000000..9955a38 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/AbstractDB2Driver.php @@ -0,0 +1,27 @@ +sqlState; + } +} diff --git a/vendor/doctrine/dbal/src/Driver/AbstractMySQLDriver.php b/vendor/doctrine/dbal/src/Driver/AbstractMySQLDriver.php new file mode 100644 index 0000000..40d6507 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/AbstractMySQLDriver.php @@ -0,0 +1,86 @@ +getServerVersion(); + if (stripos($version, 'mariadb') !== false) { + $mariaDbVersion = $this->getMariaDbMysqlVersionNumber($version); + if (version_compare($mariaDbVersion, '10.6.0', '>=')) { + return new MariaDB1060Platform(); + } + + if (version_compare($mariaDbVersion, '10.5.2', '>=')) { + return new MariaDB1052Platform(); + } + + return new MariaDBPlatform(); + } + + if (version_compare($version, '8.0.0', '>=')) { + return new MySQL80Platform(); + } + + return new MySQLPlatform(); + } + + public function getExceptionConverter(): ExceptionConverterInterface + { + return new ExceptionConverter(); + } + + /** + * Detect MariaDB server version, including hack for some mariadb distributions + * that starts with the prefix '5.5.5-' + * + * @param string $versionString Version string as returned by mariadb server, i.e. '5.5.5-Mariadb-10.0.8-xenial' + * + * @throws InvalidPlatformVersion + */ + private function getMariaDbMysqlVersionNumber(string $versionString): string + { + if ( + preg_match( + '/^(?:5\.5\.5-)?(mariadb-)?(?P\d+)\.(?P\d+)\.(?P\d+)/i', + $versionString, + $versionParts, + ) === 0 + ) { + throw InvalidPlatformVersion::new( + $versionString, + '^(?:5\.5\.5-)?(mariadb-)?..', + ); + } + + return $versionParts['major'] . '.' . $versionParts['minor'] . '.' . $versionParts['patch']; + } +} diff --git a/vendor/doctrine/dbal/src/Driver/AbstractOracleDriver.php b/vendor/doctrine/dbal/src/Driver/AbstractOracleDriver.php new file mode 100644 index 0000000..cf56cfa --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/AbstractOracleDriver.php @@ -0,0 +1,38 @@ + $params The connection parameters to return the Easy Connect String for. + */ + protected function getEasyConnectString(array $params): string + { + return (string) EasyConnectString::fromConnectionParameters($params); + } +} diff --git a/vendor/doctrine/dbal/src/Driver/AbstractOracleDriver/EasyConnectString.php b/vendor/doctrine/dbal/src/Driver/AbstractOracleDriver/EasyConnectString.php new file mode 100644 index 0000000..a777817 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/AbstractOracleDriver/EasyConnectString.php @@ -0,0 +1,112 @@ +string; + } + + /** + * Creates the object from an array representation + * + * @param mixed[] $params + */ + public static function fromArray(array $params): self + { + return new self(self::renderParams($params)); + } + + /** + * Creates the object from the given DBAL connection parameters. + * + * @param mixed[] $params + */ + public static function fromConnectionParameters(array $params): self + { + if (isset($params['connectstring'])) { + return new self($params['connectstring']); + } + + if (! isset($params['host'])) { + return new self($params['dbname'] ?? ''); + } + + $connectData = []; + + if (isset($params['servicename']) || isset($params['dbname'])) { + $serviceKey = 'SID'; + + if (isset($params['service'])) { + $serviceKey = 'SERVICE_NAME'; + } + + $serviceName = $params['servicename'] ?? $params['dbname']; + + $connectData[$serviceKey] = $serviceName; + } + + if (isset($params['instancename'])) { + $connectData['INSTANCE_NAME'] = $params['instancename']; + } + + if (! empty($params['pooled'])) { + $connectData['SERVER'] = 'POOLED'; + } + + return self::fromArray([ + 'DESCRIPTION' => [ + 'ADDRESS' => [ + 'PROTOCOL' => 'TCP', + 'HOST' => $params['host'], + 'PORT' => $params['port'] ?? 1521, + ], + 'CONNECT_DATA' => $connectData, + ], + ]); + } + + /** @param mixed[] $params */ + private static function renderParams(array $params): string + { + $chunks = []; + + foreach ($params as $key => $value) { + $string = self::renderValue($value); + + if ($string === '') { + continue; + } + + $chunks[] = sprintf('(%s=%s)', $key, $string); + } + + return implode('', $chunks); + } + + private static function renderValue(mixed $value): string + { + if (is_array($value)) { + return self::renderParams($value); + } + + return (string) $value; + } +} diff --git a/vendor/doctrine/dbal/src/Driver/AbstractPostgreSQLDriver.php b/vendor/doctrine/dbal/src/Driver/AbstractPostgreSQLDriver.php new file mode 100644 index 0000000..2efcddc --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/AbstractPostgreSQLDriver.php @@ -0,0 +1,27 @@ +exec('PRAGMA foreign_keys=ON'); + + return $connection; + } + }; + } +} diff --git a/vendor/doctrine/dbal/src/Driver/Connection.php b/vendor/doctrine/dbal/src/Driver/Connection.php new file mode 100644 index 0000000..68852e9 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/Connection.php @@ -0,0 +1,93 @@ +fetchNumeric(); + + if ($row === false) { + return false; + } + + return $row[0]; + } + + /** + * @return list> + * + * @throws Exception + */ + public static function fetchAllNumeric(Result $result): array + { + $rows = []; + + while (($row = $result->fetchNumeric()) !== false) { + $rows[] = $row; + } + + return $rows; + } + + /** + * @return list> + * + * @throws Exception + */ + public static function fetchAllAssociative(Result $result): array + { + $rows = []; + + while (($row = $result->fetchAssociative()) !== false) { + $rows[] = $row; + } + + return $rows; + } + + /** + * @return list + * + * @throws Exception + */ + public static function fetchFirstColumn(Result $result): array + { + $rows = []; + + while (($row = $result->fetchOne()) !== false) { + $rows[] = $row; + } + + return $rows; + } +} diff --git a/vendor/doctrine/dbal/src/Driver/IBMDB2/Connection.php b/vendor/doctrine/dbal/src/Driver/IBMDB2/Connection.php new file mode 100644 index 0000000..2c8783b --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/IBMDB2/Connection.php @@ -0,0 +1,131 @@ +connection); + assert($serverInfo instanceof stdClass); + + return $serverInfo->DBMS_VER; + } + + public function prepare(string $sql): Statement + { + $stmt = @db2_prepare($this->connection, $sql); + + if ($stmt === false) { + throw PrepareFailed::new(error_get_last()); + } + + return new Statement($stmt); + } + + public function query(string $sql): Result + { + return $this->prepare($sql)->execute(); + } + + public function quote(string $value): string + { + return "'" . db2_escape_string($value) . "'"; + } + + public function exec(string $sql): int|string + { + $stmt = @db2_exec($this->connection, $sql); + + if ($stmt === false) { + throw StatementError::new(); + } + + $numRows = db2_num_rows($stmt); + + if ($numRows === false) { + throw StatementError::new(); + } + + return $numRows; + } + + public function lastInsertId(): string + { + $lastInsertId = db2_last_insert_id($this->connection); + + if ($lastInsertId === null) { + throw NoIdentityValue::new(); + } + + return $lastInsertId; + } + + public function beginTransaction(): void + { + if (db2_autocommit($this->connection, DB2_AUTOCOMMIT_OFF) !== true) { + throw ConnectionError::new($this->connection); + } + } + + public function commit(): void + { + if (! db2_commit($this->connection)) { + throw ConnectionError::new($this->connection); + } + + if (db2_autocommit($this->connection, DB2_AUTOCOMMIT_ON) !== true) { + throw ConnectionError::new($this->connection); + } + } + + public function rollBack(): void + { + if (! db2_rollback($this->connection)) { + throw ConnectionError::new($this->connection); + } + + if (db2_autocommit($this->connection, DB2_AUTOCOMMIT_ON) !== true) { + throw ConnectionError::new($this->connection); + } + } + + /** @return resource */ + public function getNativeConnection() + { + return $this->connection; + } +} diff --git a/vendor/doctrine/dbal/src/Driver/IBMDB2/DataSourceName.php b/vendor/doctrine/dbal/src/Driver/IBMDB2/DataSourceName.php new file mode 100644 index 0000000..a1e5948 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/IBMDB2/DataSourceName.php @@ -0,0 +1,80 @@ +string; + } + + /** + * Creates the object from an array representation + * + * @param array $params + */ + public static function fromArray( + #[SensitiveParameter] + array $params, + ): self { + $chunks = []; + + foreach ($params as $key => $value) { + $chunks[] = sprintf('%s=%s', $key, $value); + } + + return new self(implode(';', $chunks)); + } + + /** + * Creates the object from the given DBAL connection parameters. + * + * @param array $params + */ + public static function fromConnectionParameters(#[SensitiveParameter] + array $params,): self + { + if (isset($params['dbname']) && str_contains($params['dbname'], '=')) { + return new self($params['dbname']); + } + + $dsnParams = []; + + foreach ( + [ + 'host' => 'HOSTNAME', + 'port' => 'PORT', + 'protocol' => 'PROTOCOL', + 'dbname' => 'DATABASE', + 'user' => 'UID', + 'password' => 'PWD', + ] as $dbalParam => $dsnParam + ) { + if (! isset($params[$dbalParam])) { + continue; + } + + $dsnParams[$dsnParam] = $params[$dbalParam]; + } + + return self::fromArray($dsnParams); + } +} diff --git a/vendor/doctrine/dbal/src/Driver/IBMDB2/Driver.php b/vendor/doctrine/dbal/src/Driver/IBMDB2/Driver.php new file mode 100644 index 0000000..f2f4ed7 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/IBMDB2/Driver.php @@ -0,0 +1,41 @@ +toString(); + + $username = $params['user'] ?? ''; + $password = $params['password'] ?? ''; + $driverOptions = $params['driverOptions'] ?? []; + + if (! empty($params['persistent'])) { + $connection = db2_pconnect($dataSourceName, $username, $password, $driverOptions); + } else { + $connection = db2_connect($dataSourceName, $username, $password, $driverOptions); + } + + if ($connection === false) { + throw ConnectionFailed::new(); + } + + return new Connection($connection); + } +} diff --git a/vendor/doctrine/dbal/src/Driver/IBMDB2/Exception/CannotCopyStreamToStream.php b/vendor/doctrine/dbal/src/Driver/IBMDB2/Exception/CannotCopyStreamToStream.php new file mode 100644 index 0000000..c584fb8 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/IBMDB2/Exception/CannotCopyStreamToStream.php @@ -0,0 +1,27 @@ +statement); + + if ($row === false && db2_stmt_error($this->statement) !== '02000') { + throw StatementError::new($this->statement); + } + + return $row; + } + + public function fetchAssociative(): array|false + { + $row = @db2_fetch_assoc($this->statement); + + if ($row === false && db2_stmt_error($this->statement) !== '02000') { + throw StatementError::new($this->statement); + } + + return $row; + } + + public function fetchOne(): mixed + { + return FetchUtils::fetchOne($this); + } + + /** + * {@inheritDoc} + */ + public function fetchAllNumeric(): array + { + return FetchUtils::fetchAllNumeric($this); + } + + /** + * {@inheritDoc} + */ + public function fetchAllAssociative(): array + { + return FetchUtils::fetchAllAssociative($this); + } + + /** + * {@inheritDoc} + */ + public function fetchFirstColumn(): array + { + return FetchUtils::fetchFirstColumn($this); + } + + public function rowCount(): int + { + $numRows = @db2_num_rows($this->statement); + + if ($numRows === false) { + throw StatementError::new($this->statement); + } + + return $numRows; + } + + public function columnCount(): int + { + $count = db2_num_fields($this->statement); + + if ($count !== false) { + return $count; + } + + return 0; + } + + public function free(): void + { + db2_free_result($this->statement); + } +} diff --git a/vendor/doctrine/dbal/src/Driver/IBMDB2/Statement.php b/vendor/doctrine/dbal/src/Driver/IBMDB2/Statement.php new file mode 100644 index 0000000..96852da --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/IBMDB2/Statement.php @@ -0,0 +1,156 @@ + + */ + private array $lobs = []; + + /** + * @internal The statement can be only instantiated by its driver connection. + * + * @param resource $stmt + */ + public function __construct(private readonly mixed $stmt) + { + } + + public function bindValue(int|string $param, mixed $value, ParameterType $type): void + { + assert(is_int($param)); + + switch ($type) { + case ParameterType::INTEGER: + $this->bind($param, $value, DB2_PARAM_IN, DB2_LONG); + break; + + case ParameterType::LARGE_OBJECT: + $this->lobs[$param] = &$value; + break; + + default: + $this->bind($param, $value, DB2_PARAM_IN, DB2_CHAR); + break; + } + } + + /** @throws Exception */ + private function bind(int $position, mixed &$variable, int $parameterType, int $dataType): void + { + $this->parameters[$position] =& $variable; + + if (! db2_bind_param($this->stmt, $position, '', $parameterType, $dataType)) { + throw StatementError::new($this->stmt); + } + } + + public function execute(): Result + { + $handles = $this->bindLobs(); + + $result = @db2_execute($this->stmt, $this->parameters); + + foreach ($handles as $handle) { + fclose($handle); + } + + $this->lobs = []; + + if ($result === false) { + throw StatementError::new($this->stmt); + } + + return new Result($this->stmt); + } + + /** + * @return list + * + * @throws Exception + */ + private function bindLobs(): array + { + $handles = []; + + foreach ($this->lobs as $param => $value) { + if (is_resource($value)) { + $handle = $handles[] = $this->createTemporaryFile(); + $path = stream_get_meta_data($handle)['uri']; + + $this->copyStreamToStream($value, $handle); + + $this->bind($param, $path, DB2_PARAM_FILE, DB2_BINARY); + } else { + $this->bind($param, $value, DB2_PARAM_IN, DB2_CHAR); + } + + unset($value); + } + + return $handles; + } + + /** + * @return resource + * + * @throws Exception + */ + private function createTemporaryFile() + { + $handle = @tmpfile(); + + if ($handle === false) { + throw CannotCreateTemporaryFile::new(error_get_last()); + } + + return $handle; + } + + /** + * @param resource $source + * @param resource $target + * + * @throws Exception + */ + private function copyStreamToStream($source, $target): void + { + if (@stream_copy_to_stream($source, $target) === false) { + throw CannotCopyStreamToStream::new(error_get_last()); + } + } +} diff --git a/vendor/doctrine/dbal/src/Driver/Middleware.php b/vendor/doctrine/dbal/src/Driver/Middleware.php new file mode 100644 index 0000000..4629d9a --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/Middleware.php @@ -0,0 +1,12 @@ +wrappedConnection->prepare($sql); + } + + public function query(string $sql): Result + { + return $this->wrappedConnection->query($sql); + } + + public function quote(string $value): string + { + return $this->wrappedConnection->quote($value); + } + + public function exec(string $sql): int|string + { + return $this->wrappedConnection->exec($sql); + } + + public function lastInsertId(): int|string + { + return $this->wrappedConnection->lastInsertId(); + } + + public function beginTransaction(): void + { + $this->wrappedConnection->beginTransaction(); + } + + public function commit(): void + { + $this->wrappedConnection->commit(); + } + + public function rollBack(): void + { + $this->wrappedConnection->rollBack(); + } + + public function getServerVersion(): string + { + return $this->wrappedConnection->getServerVersion(); + } + + /** + * {@inheritDoc} + */ + public function getNativeConnection() + { + return $this->wrappedConnection->getNativeConnection(); + } +} diff --git a/vendor/doctrine/dbal/src/Driver/Middleware/AbstractDriverMiddleware.php b/vendor/doctrine/dbal/src/Driver/Middleware/AbstractDriverMiddleware.php new file mode 100644 index 0000000..482f134 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/Middleware/AbstractDriverMiddleware.php @@ -0,0 +1,39 @@ +wrappedDriver->connect($params); + } + + public function getDatabasePlatform(ServerVersionProvider $versionProvider): AbstractPlatform + { + return $this->wrappedDriver->getDatabasePlatform($versionProvider); + } + + public function getExceptionConverter(): ExceptionConverter + { + return $this->wrappedDriver->getExceptionConverter(); + } +} diff --git a/vendor/doctrine/dbal/src/Driver/Middleware/AbstractResultMiddleware.php b/vendor/doctrine/dbal/src/Driver/Middleware/AbstractResultMiddleware.php new file mode 100644 index 0000000..7da2f99 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/Middleware/AbstractResultMiddleware.php @@ -0,0 +1,68 @@ +wrappedResult->fetchNumeric(); + } + + public function fetchAssociative(): array|false + { + return $this->wrappedResult->fetchAssociative(); + } + + public function fetchOne(): mixed + { + return $this->wrappedResult->fetchOne(); + } + + /** + * {@inheritDoc} + */ + public function fetchAllNumeric(): array + { + return $this->wrappedResult->fetchAllNumeric(); + } + + /** + * {@inheritDoc} + */ + public function fetchAllAssociative(): array + { + return $this->wrappedResult->fetchAllAssociative(); + } + + /** + * {@inheritDoc} + */ + public function fetchFirstColumn(): array + { + return $this->wrappedResult->fetchFirstColumn(); + } + + public function rowCount(): int|string + { + return $this->wrappedResult->rowCount(); + } + + public function columnCount(): int + { + return $this->wrappedResult->columnCount(); + } + + public function free(): void + { + $this->wrappedResult->free(); + } +} diff --git a/vendor/doctrine/dbal/src/Driver/Middleware/AbstractStatementMiddleware.php b/vendor/doctrine/dbal/src/Driver/Middleware/AbstractStatementMiddleware.php new file mode 100644 index 0000000..6eaad50 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/Middleware/AbstractStatementMiddleware.php @@ -0,0 +1,26 @@ +wrappedStatement->bindValue($param, $value, $type); + } + + public function execute(): Result + { + return $this->wrappedStatement->execute(); + } +} diff --git a/vendor/doctrine/dbal/src/Driver/Mysqli/Connection.php b/vendor/doctrine/dbal/src/Driver/Mysqli/Connection.php new file mode 100644 index 0000000..cc00fb6 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/Mysqli/Connection.php @@ -0,0 +1,112 @@ +connection->get_server_info(); + } + + public function prepare(string $sql): Statement + { + try { + $stmt = $this->connection->prepare($sql); + } catch (mysqli_sql_exception $e) { + throw ConnectionError::upcast($e); + } + + if ($stmt === false) { + throw ConnectionError::new($this->connection); + } + + return new Statement($stmt); + } + + public function query(string $sql): Result + { + return $this->prepare($sql)->execute(); + } + + public function quote(string $value): string + { + return "'" . $this->connection->escape_string($value) . "'"; + } + + public function exec(string $sql): int|string + { + try { + $result = $this->connection->query($sql); + } catch (mysqli_sql_exception $e) { + throw ConnectionError::upcast($e); + } + + if ($result === false) { + throw ConnectionError::new($this->connection); + } + + return $this->connection->affected_rows; + } + + public function lastInsertId(): int|string + { + $lastInsertId = $this->connection->insert_id; + + if ($lastInsertId === 0) { + throw Exception\NoIdentityValue::new(); + } + + return $this->connection->insert_id; + } + + public function beginTransaction(): void + { + $this->connection->begin_transaction(); + } + + public function commit(): void + { + try { + if (! $this->connection->commit()) { + throw ConnectionError::new($this->connection); + } + } catch (mysqli_sql_exception $e) { + throw ConnectionError::upcast($e); + } + } + + public function rollBack(): void + { + try { + if (! $this->connection->rollback()) { + throw ConnectionError::new($this->connection); + } + } catch (mysqli_sql_exception $e) { + throw ConnectionError::upcast($e); + } + } + + public function getNativeConnection(): mysqli + { + return $this->connection; + } +} diff --git a/vendor/doctrine/dbal/src/Driver/Mysqli/Driver.php b/vendor/doctrine/dbal/src/Driver/Mysqli/Driver.php new file mode 100644 index 0000000..9855e56 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/Mysqli/Driver.php @@ -0,0 +1,117 @@ +compilePreInitializers($params) as $initializer) { + $initializer->initialize($connection); + } + + try { + $success = @$connection->real_connect( + $host, + $params['user'] ?? '', + $params['password'] ?? '', + $params['dbname'] ?? '', + $params['port'] ?? 0, + $params['unix_socket'] ?? '', + $params['driverOptions'][Connection::OPTION_FLAGS] ?? 0, + ); + } catch (mysqli_sql_exception $e) { + throw ConnectionFailed::upcast($e); + } + + if (! $success) { + throw ConnectionFailed::new($connection); + } + + foreach ($this->compilePostInitializers($params) as $initializer) { + $initializer->initialize($connection); + } + + return new Connection($connection); + } + + /** + * @param array $params + * + * @return Generator + */ + private function compilePreInitializers( + #[SensitiveParameter] + array $params, + ): Generator { + unset($params['driverOptions'][Connection::OPTION_FLAGS]); + + if (isset($params['driverOptions']) && $params['driverOptions'] !== []) { + yield new Options($params['driverOptions']); + } + + if ( + ! isset($params['ssl_key']) && + ! isset($params['ssl_cert']) && + ! isset($params['ssl_ca']) && + ! isset($params['ssl_capath']) && + ! isset($params['ssl_cipher']) + ) { + return; + } + + yield new Secure( + $params['ssl_key'] ?? '', + $params['ssl_cert'] ?? '', + $params['ssl_ca'] ?? '', + $params['ssl_capath'] ?? '', + $params['ssl_cipher'] ?? '', + ); + } + + /** + * @param array $params + * + * @return Generator + */ + private function compilePostInitializers( + #[SensitiveParameter] + array $params, + ): Generator { + if (! isset($params['charset'])) { + return; + } + + yield new Charset($params['charset']); + } +} diff --git a/vendor/doctrine/dbal/src/Driver/Mysqli/Exception/ConnectionError.php b/vendor/doctrine/dbal/src/Driver/Mysqli/Exception/ConnectionError.php new file mode 100644 index 0000000..d2477fd --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/Mysqli/Exception/ConnectionError.php @@ -0,0 +1,30 @@ +error, $connection->sqlstate, $connection->errno); + } + + public static function upcast(mysqli_sql_exception $exception): self + { + $p = new ReflectionProperty(mysqli_sql_exception::class, 'sqlstate'); + + return new self($exception->getMessage(), $p->getValue($exception), $exception->getCode(), $exception); + } +} diff --git a/vendor/doctrine/dbal/src/Driver/Mysqli/Exception/ConnectionFailed.php b/vendor/doctrine/dbal/src/Driver/Mysqli/Exception/ConnectionFailed.php new file mode 100644 index 0000000..cb3bc64 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/Mysqli/Exception/ConnectionFailed.php @@ -0,0 +1,35 @@ +connect_error; + assert($error !== null); + + return new self($error, 'HY000', $connection->connect_errno); + } + + public static function upcast(mysqli_sql_exception $exception): self + { + $p = new ReflectionProperty(mysqli_sql_exception::class, 'sqlstate'); + + return new self($exception->getMessage(), $p->getValue($exception), $exception->getCode(), $exception); + } +} diff --git a/vendor/doctrine/dbal/src/Driver/Mysqli/Exception/FailedReadingStreamOffset.php b/vendor/doctrine/dbal/src/Driver/Mysqli/Exception/FailedReadingStreamOffset.php new file mode 100644 index 0000000..6f26dbe --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/Mysqli/Exception/FailedReadingStreamOffset.php @@ -0,0 +1,22 @@ +error), + $connection->sqlstate, + $connection->errno, + ); + } + + public static function upcast(mysqli_sql_exception $exception, string $charset): self + { + $p = new ReflectionProperty(mysqli_sql_exception::class, 'sqlstate'); + + return new self( + sprintf('Failed to set charset "%s": %s', $charset, $exception->getMessage()), + $p->getValue($exception), + $exception->getCode(), + $exception, + ); + } +} diff --git a/vendor/doctrine/dbal/src/Driver/Mysqli/Exception/InvalidOption.php b/vendor/doctrine/dbal/src/Driver/Mysqli/Exception/InvalidOption.php new file mode 100644 index 0000000..654bb87 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/Mysqli/Exception/InvalidOption.php @@ -0,0 +1,24 @@ +error, $statement->sqlstate, $statement->errno); + } + + public static function upcast(mysqli_sql_exception $exception): self + { + $p = new ReflectionProperty(mysqli_sql_exception::class, 'sqlstate'); + + return new self($exception->getMessage(), $p->getValue($exception), $exception->getCode(), $exception); + } +} diff --git a/vendor/doctrine/dbal/src/Driver/Mysqli/Initializer.php b/vendor/doctrine/dbal/src/Driver/Mysqli/Initializer.php new file mode 100644 index 0000000..efab67e --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/Mysqli/Initializer.php @@ -0,0 +1,14 @@ +set_charset($this->charset); + } catch (mysqli_sql_exception $e) { + throw InvalidCharset::upcast($e, $this->charset); + } + + if ($success) { + return; + } + + throw InvalidCharset::fromCharset($connection, $this->charset); + } +} diff --git a/vendor/doctrine/dbal/src/Driver/Mysqli/Initializer/Options.php b/vendor/doctrine/dbal/src/Driver/Mysqli/Initializer/Options.php new file mode 100644 index 0000000..3223951 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/Mysqli/Initializer/Options.php @@ -0,0 +1,28 @@ + $options */ + public function __construct(private readonly array $options) + { + } + + public function initialize(mysqli $connection): void + { + foreach ($this->options as $option => $value) { + if (! mysqli_options($connection, $option, $value)) { + throw InvalidOption::fromOption($option, $value); + } + } + } +} diff --git a/vendor/doctrine/dbal/src/Driver/Mysqli/Initializer/Secure.php b/vendor/doctrine/dbal/src/Driver/Mysqli/Initializer/Secure.php new file mode 100644 index 0000000..fa819b5 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/Mysqli/Initializer/Secure.php @@ -0,0 +1,27 @@ +ssl_set($this->key, $this->cert, $this->ca, $this->capath, $this->cipher); + } +} diff --git a/vendor/doctrine/dbal/src/Driver/Mysqli/Result.php b/vendor/doctrine/dbal/src/Driver/Mysqli/Result.php new file mode 100644 index 0000000..8d3c47a --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/Mysqli/Result.php @@ -0,0 +1,164 @@ + + */ + private readonly array $columnNames; + + /** @var mixed[] */ + private array $boundValues = []; + + /** + * @internal The result can be only instantiated by its driver connection or statement. + * + * @throws Exception + */ + public function __construct(private readonly mysqli_stmt $statement) + { + $meta = $statement->result_metadata(); + $this->hasColumns = $meta !== false; + $this->columnNames = $meta !== false ? array_column($meta->fetch_fields(), 'name') : []; + + if ($meta === false) { + return; + } + + $meta->free(); + + // Store result of every execution which has it. Otherwise it will be impossible + // to execute a new statement in case if the previous one has non-fetched rows + // @link http://dev.mysql.com/doc/refman/5.7/en/commands-out-of-sync.html + $this->statement->store_result(); + + // Bind row values _after_ storing the result. Otherwise, if mysqli is compiled with libmysql, + // it will have to allocate as much memory as it may be needed for the given column type + // (e.g. for a LONGBLOB column it's 4 gigabytes) + // @link https://bugs.php.net/bug.php?id=51386#1270673122 + // + // Make sure that the values are bound after each execution. Otherwise, if free() has been + // previously called on the result, the values are unbound making the statement unusable. + // + // It's also important that row values are bound after _each_ call to store_result(). Otherwise, + // if mysqli is compiled with libmysql, subsequently fetched string values will get truncated + // to the length of the ones fetched during the previous execution. + $this->boundValues = array_fill(0, count($this->columnNames), null); + + // The following is necessary as PHP cannot handle references to properties properly + $refs = &$this->boundValues; + + if (! $this->statement->bind_result(...$refs)) { + throw StatementError::new($this->statement); + } + } + + public function fetchNumeric(): array|false + { + try { + $ret = $this->statement->fetch(); + } catch (mysqli_sql_exception $e) { + throw StatementError::upcast($e); + } + + if ($ret === false) { + throw StatementError::new($this->statement); + } + + if ($ret === null) { + return false; + } + + $values = []; + + foreach ($this->boundValues as $v) { + $values[] = $v; + } + + return $values; + } + + public function fetchAssociative(): array|false + { + $values = $this->fetchNumeric(); + + if ($values === false) { + return false; + } + + return array_combine($this->columnNames, $values); + } + + public function fetchOne(): mixed + { + return FetchUtils::fetchOne($this); + } + + /** + * {@inheritDoc} + */ + public function fetchAllNumeric(): array + { + return FetchUtils::fetchAllNumeric($this); + } + + /** + * {@inheritDoc} + */ + public function fetchAllAssociative(): array + { + return FetchUtils::fetchAllAssociative($this); + } + + /** + * {@inheritDoc} + */ + public function fetchFirstColumn(): array + { + return FetchUtils::fetchFirstColumn($this); + } + + public function rowCount(): int|string + { + if ($this->hasColumns) { + return $this->statement->num_rows; + } + + return $this->statement->affected_rows; + } + + public function columnCount(): int + { + return $this->statement->field_count; + } + + public function free(): void + { + $this->statement->free_result(); + } +} diff --git a/vendor/doctrine/dbal/src/Driver/Mysqli/Statement.php b/vendor/doctrine/dbal/src/Driver/Mysqli/Statement.php new file mode 100644 index 0000000..8436fad --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/Mysqli/Statement.php @@ -0,0 +1,154 @@ +stmt->param_count; + $this->types = str_repeat(self::PARAMETER_TYPE_STRING, $paramCount); + $this->boundValues = array_fill(1, $paramCount, null); + } + + public function bindValue(int|string $param, mixed $value, ParameterType $type): void + { + assert(is_int($param)); + + $this->types[$param - 1] = $this->convertParameterType($type); + $this->values[$param] = $value; + $this->boundValues[$param] =& $this->values[$param]; + } + + public function execute(): Result + { + if (count($this->boundValues) > 0) { + $this->bindParameters(); + } + + try { + if (! $this->stmt->execute()) { + throw StatementError::new($this->stmt); + } + } catch (mysqli_sql_exception $e) { + throw StatementError::upcast($e); + } + + return new Result($this->stmt); + } + + /** + * Binds parameters with known types previously bound to the statement + * + * @throws Exception + */ + private function bindParameters(): void + { + $streams = $values = []; + $types = $this->types; + + foreach ($this->boundValues as $parameter => $value) { + assert(is_int($parameter)); + if (! isset($types[$parameter - 1])) { + $types[$parameter - 1] = self::PARAMETER_TYPE_STRING; + } + + if ($types[$parameter - 1] === self::PARAMETER_TYPE_BINARY) { + if (is_resource($value)) { + if (get_resource_type($value) !== 'stream') { + throw NonStreamResourceUsedAsLargeObject::new($parameter); + } + + $streams[$parameter] = $value; + $values[$parameter] = null; + continue; + } + + $types[$parameter - 1] = self::PARAMETER_TYPE_STRING; + } + + $values[$parameter] = $value; + } + + if (! $this->stmt->bind_param($types, ...$values)) { + throw StatementError::new($this->stmt); + } + + $this->sendLongData($streams); + } + + /** + * Handle $this->_longData after regular query parameters have been bound + * + * @param array $streams + * + * @throws Exception + */ + private function sendLongData(array $streams): void + { + foreach ($streams as $paramNr => $stream) { + while (! feof($stream)) { + $chunk = fread($stream, 8192); + + if ($chunk === false) { + throw FailedReadingStreamOffset::new($paramNr); + } + + if (! $this->stmt->send_long_data($paramNr - 1, $chunk)) { + throw StatementError::new($this->stmt); + } + } + } + } + + private function convertParameterType(ParameterType $type): string + { + return match ($type) { + ParameterType::NULL, + ParameterType::STRING, + ParameterType::ASCII, + ParameterType::BINARY => self::PARAMETER_TYPE_STRING, + ParameterType::INTEGER, + ParameterType::BOOLEAN => self::PARAMETER_TYPE_INTEGER, + ParameterType::LARGE_OBJECT => self::PARAMETER_TYPE_BINARY, + }; + } +} diff --git a/vendor/doctrine/dbal/src/Driver/OCI8/Connection.php b/vendor/doctrine/dbal/src/Driver/OCI8/Connection.php new file mode 100644 index 0000000..3652ca0 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/OCI8/Connection.php @@ -0,0 +1,119 @@ +parser = new Parser(false); + $this->executionMode = new ExecutionMode(); + } + + public function getServerVersion(): string + { + $version = oci_server_version($this->connection); + assert($version !== false); + + $result = preg_match('/\s+(\d+\.\d+\.\d+\.\d+\.\d+)\s+/', $version, $matches); + assert($result === 1); + + return $matches[1]; + } + + /** @throws Parser\Exception */ + public function prepare(string $sql): Statement + { + $visitor = new ConvertPositionalToNamedPlaceholders(); + + $this->parser->parse($sql, $visitor); + + $statement = oci_parse($this->connection, $visitor->getSQL()); + assert(is_resource($statement)); + + return new Statement($this->connection, $statement, $visitor->getParameterMap(), $this->executionMode); + } + + /** + * @throws Exception + * @throws Parser\Exception + */ + public function query(string $sql): Result + { + return $this->prepare($sql)->execute(); + } + + public function quote(string $value): string + { + return "'" . addcslashes(str_replace("'", "''", $value), "\000\n\r\\\032") . "'"; + } + + /** + * @throws Exception + * @throws Parser\Exception + */ + public function exec(string $sql): int|string + { + return $this->prepare($sql)->execute()->rowCount(); + } + + public function lastInsertId(): int|string + { + throw IdentityColumnsNotSupported::new(); + } + + public function beginTransaction(): void + { + $this->executionMode->disableAutoCommit(); + } + + public function commit(): void + { + if (! oci_commit($this->connection)) { + throw Error::new($this->connection); + } + + $this->executionMode->enableAutoCommit(); + } + + public function rollBack(): void + { + if (! oci_rollback($this->connection)) { + throw Error::new($this->connection); + } + + $this->executionMode->enableAutoCommit(); + } + + /** @return resource */ + public function getNativeConnection() + { + return $this->connection; + } +} diff --git a/vendor/doctrine/dbal/src/Driver/OCI8/ConvertPositionalToNamedPlaceholders.php b/vendor/doctrine/dbal/src/Driver/OCI8/ConvertPositionalToNamedPlaceholders.php new file mode 100644 index 0000000..5898a2c --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/OCI8/ConvertPositionalToNamedPlaceholders.php @@ -0,0 +1,58 @@ +). + * + * Oracle does not support positional parameters, hence this method converts all + * positional parameters into artificially named parameters. + * + * @internal This class is not covered by the backward compatibility promise + */ +final class ConvertPositionalToNamedPlaceholders implements Visitor +{ + /** @var list */ + private array $buffer = []; + + /** @var array */ + private array $parameterMap = []; + + public function acceptOther(string $sql): void + { + $this->buffer[] = $sql; + } + + public function acceptPositionalParameter(string $sql): void + { + $position = count($this->parameterMap) + 1; + $param = ':param' . $position; + + $this->parameterMap[$position] = $param; + + $this->buffer[] = $param; + } + + public function acceptNamedParameter(string $sql): void + { + $this->buffer[] = $sql; + } + + public function getSQL(): string + { + return implode('', $this->buffer); + } + + /** @return array */ + public function getParameterMap(): array + { + return $this->parameterMap; + } +} diff --git a/vendor/doctrine/dbal/src/Driver/OCI8/Driver.php b/vendor/doctrine/dbal/src/Driver/OCI8/Driver.php new file mode 100644 index 0000000..1b0afbf --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/OCI8/Driver.php @@ -0,0 +1,60 @@ +getEasyConnectString($params); + + /** @psalm-suppress RiskyTruthyFalsyComparison */ + $persistent = ! empty($params['persistent']); + /** @psalm-suppress RiskyTruthyFalsyComparison */ + $exclusive = ! empty($params['driverOptions']['exclusive']); + + if ($persistent && $exclusive) { + throw InvalidConfiguration::forPersistentAndExclusive(); + } + + if ($persistent) { + $connection = @oci_pconnect($username, $password, $connectionString, $charset, $sessionMode); + } elseif ($exclusive) { + $connection = @oci_new_connect($username, $password, $connectionString, $charset, $sessionMode); + } else { + $connection = @oci_connect($username, $password, $connectionString, $charset, $sessionMode); + } + + if ($connection === false) { + throw ConnectionFailed::new(); + } + + return new Connection($connection); + } +} diff --git a/vendor/doctrine/dbal/src/Driver/OCI8/Exception/ConnectionFailed.php b/vendor/doctrine/dbal/src/Driver/OCI8/Exception/ConnectionFailed.php new file mode 100644 index 0000000..cefe9a3 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/OCI8/Exception/ConnectionFailed.php @@ -0,0 +1,26 @@ +isAutoCommitEnabled = true; + } + + public function disableAutoCommit(): void + { + $this->isAutoCommitEnabled = false; + } + + public function isAutoCommitEnabled(): bool + { + return $this->isAutoCommitEnabled; + } +} diff --git a/vendor/doctrine/dbal/src/Driver/OCI8/Middleware/InitializeSession.php b/vendor/doctrine/dbal/src/Driver/OCI8/Middleware/InitializeSession.php new file mode 100644 index 0000000..b825a1a --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/OCI8/Middleware/InitializeSession.php @@ -0,0 +1,40 @@ +exec( + 'ALTER SESSION SET' + . " NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS'" + . " NLS_TIME_FORMAT = 'HH24:MI:SS'" + . " NLS_TIMESTAMP_FORMAT = 'YYYY-MM-DD HH24:MI:SS'" + . " NLS_TIMESTAMP_TZ_FORMAT = 'YYYY-MM-DD HH24:MI:SS TZH:TZM'" + . " NLS_NUMERIC_CHARACTERS = '.,'", + ); + + return $connection; + } + }; + } +} diff --git a/vendor/doctrine/dbal/src/Driver/OCI8/Result.php b/vendor/doctrine/dbal/src/Driver/OCI8/Result.php new file mode 100644 index 0000000..609e651 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/OCI8/Result.php @@ -0,0 +1,128 @@ +fetch(OCI_NUM); + } + + public function fetchAssociative(): array|false + { + return $this->fetch(OCI_ASSOC); + } + + public function fetchOne(): mixed + { + return FetchUtils::fetchOne($this); + } + + /** + * {@inheritDoc} + */ + public function fetchAllNumeric(): array + { + return $this->fetchAll(OCI_NUM, OCI_FETCHSTATEMENT_BY_ROW); + } + + /** + * {@inheritDoc} + */ + public function fetchAllAssociative(): array + { + return $this->fetchAll(OCI_ASSOC, OCI_FETCHSTATEMENT_BY_ROW); + } + + /** + * {@inheritDoc} + */ + public function fetchFirstColumn(): array + { + return $this->fetchAll(OCI_NUM, OCI_FETCHSTATEMENT_BY_COLUMN)[0]; + } + + public function rowCount(): int + { + $count = oci_num_rows($this->statement); + + if ($count !== false) { + return $count; + } + + return 0; + } + + public function columnCount(): int + { + $count = oci_num_fields($this->statement); + + if ($count !== false) { + return $count; + } + + return 0; + } + + public function free(): void + { + oci_cancel($this->statement); + } + + /** @throws Exception */ + private function fetch(int $mode): mixed + { + $result = oci_fetch_array($this->statement, $mode | OCI_RETURN_NULLS | OCI_RETURN_LOBS); + + if ($result === false && oci_error($this->statement) !== false) { + throw Error::new($this->statement); + } + + return $result; + } + + /** @return array */ + private function fetchAll(int $mode, int $fetchStructure): array + { + oci_fetch_all( + $this->statement, + $result, + 0, + -1, + $mode | OCI_RETURN_NULLS | $fetchStructure | OCI_RETURN_LOBS, + ); + + return $result; + } +} diff --git a/vendor/doctrine/dbal/src/Driver/OCI8/Statement.php b/vendor/doctrine/dbal/src/Driver/OCI8/Statement.php new file mode 100644 index 0000000..408f0dd --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/OCI8/Statement.php @@ -0,0 +1,103 @@ + $parameterMap + */ + public function __construct( + private readonly mixed $connection, + private readonly mixed $statement, + private readonly array $parameterMap, + private readonly ExecutionMode $executionMode, + ) { + } + + public function bindValue(int|string $param, mixed $value, ParameterType $type): void + { + if (is_int($param)) { + if (! isset($this->parameterMap[$param])) { + throw UnknownParameterIndex::new($param); + } + + $param = $this->parameterMap[$param]; + } + + if ($type === ParameterType::LARGE_OBJECT) { + if ($value !== null) { + $lob = oci_new_descriptor($this->connection, OCI_D_LOB); + $lob->writeTemporary($value, OCI_TEMP_BLOB); + + $value =& $lob; + } else { + $type = ParameterType::STRING; + } + } + + if ( + ! @oci_bind_by_name( + $this->statement, + $param, + $value, + -1, + $this->convertParameterType($type), + ) + ) { + throw Error::new($this->statement); + } + } + + /** + * Converts DBAL parameter type to oci8 parameter type + */ + private function convertParameterType(ParameterType $type): int + { + return match ($type) { + ParameterType::BINARY => OCI_B_BIN, + ParameterType::LARGE_OBJECT => OCI_B_BLOB, + default => SQLT_CHR, + }; + } + + public function execute(): Result + { + if ($this->executionMode->isAutoCommitEnabled()) { + $mode = OCI_COMMIT_ON_SUCCESS; + } else { + $mode = OCI_NO_AUTO_COMMIT; + } + + $ret = @oci_execute($this->statement, $mode); + if (! $ret) { + throw Error::new($this->statement); + } + + return new Result($this->statement); + } +} diff --git a/vendor/doctrine/dbal/src/Driver/PDO/Connection.php b/vendor/doctrine/dbal/src/Driver/PDO/Connection.php new file mode 100644 index 0000000..b1faca1 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/PDO/Connection.php @@ -0,0 +1,133 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + } + + public function exec(string $sql): int + { + try { + $result = $this->connection->exec($sql); + + assert($result !== false); + + return $result; + } catch (PDOException $exception) { + throw Exception::new($exception); + } + } + + public function getServerVersion(): string + { + return $this->connection->getAttribute(PDO::ATTR_SERVER_VERSION); + } + + public function prepare(string $sql): Statement + { + try { + $stmt = $this->connection->prepare($sql); + assert($stmt instanceof PDOStatement); + + return new Statement($stmt); + } catch (PDOException $exception) { + throw Exception::new($exception); + } + } + + public function query(string $sql): Result + { + try { + $stmt = $this->connection->query($sql); + assert($stmt instanceof PDOStatement); + + return new Result($stmt); + } catch (PDOException $exception) { + throw Exception::new($exception); + } + } + + public function quote(string $value): string + { + return $this->connection->quote($value); + } + + public function lastInsertId(): int|string + { + try { + $value = $this->connection->lastInsertId(); + } catch (PDOException $exception) { + assert($exception->errorInfo !== null); + [$sqlState] = $exception->errorInfo; + + // if the PDO driver does not support this capability, PDO::lastInsertId() triggers an IM001 SQLSTATE + // see https://www.php.net/manual/en/pdo.lastinsertid.php + if ($sqlState === 'IM001') { + throw IdentityColumnsNotSupported::new(); + } + + // PDO PGSQL throws a 'lastval is not yet defined in this session' error when no identity value is + // available, with SQLSTATE 55000 'Object Not In Prerequisite State' + if ($sqlState === '55000' && $this->connection->getAttribute(PDO::ATTR_DRIVER_NAME) === 'pgsql') { + throw NoIdentityValue::new($exception); + } + + throw Exception::new($exception); + } + + // pdo_mysql & pdo_sqlite return '0', pdo_sqlsrv returns '' or false depending on the PHP version + if ($value === '0' || $value === '' || $value === false) { + throw NoIdentityValue::new(); + } + + return $value; + } + + public function beginTransaction(): void + { + try { + $this->connection->beginTransaction(); + } catch (PDOException $exception) { + throw Exception::new($exception); + } + } + + public function commit(): void + { + try { + $this->connection->commit(); + } catch (PDOException $exception) { + throw Exception::new($exception); + } + } + + public function rollBack(): void + { + try { + $this->connection->rollBack(); + } catch (PDOException $exception) { + throw Exception::new($exception); + } + } + + public function getNativeConnection(): PDO + { + return $this->connection; + } +} diff --git a/vendor/doctrine/dbal/src/Driver/PDO/Exception.php b/vendor/doctrine/dbal/src/Driver/PDO/Exception.php new file mode 100644 index 0000000..fbb8125 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/PDO/Exception.php @@ -0,0 +1,30 @@ +errorInfo !== null) { + [$sqlState, $code] = $exception->errorInfo; + + $code ??= 0; + } else { + $code = $exception->getCode(); + $sqlState = null; + } + + return new self($exception->getMessage(), $sqlState, $code, $exception); + } +} diff --git a/vendor/doctrine/dbal/src/Driver/PDO/MySQL/Driver.php b/vendor/doctrine/dbal/src/Driver/PDO/MySQL/Driver.php new file mode 100644 index 0000000..963fef0 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/PDO/MySQL/Driver.php @@ -0,0 +1,76 @@ +constructPdoDsn($safeParams), + $params['user'] ?? '', + $params['password'] ?? '', + $driverOptions, + ); + } catch (PDOException $exception) { + throw Exception::new($exception); + } + + return new Connection($pdo); + } + + /** + * Constructs the MySQL PDO DSN. + * + * @param mixed[] $params + */ + private function constructPdoDsn(array $params): string + { + $dsn = 'mysql:'; + if (isset($params['host']) && $params['host'] !== '') { + $dsn .= 'host=' . $params['host'] . ';'; + } + + if (isset($params['port'])) { + $dsn .= 'port=' . $params['port'] . ';'; + } + + if (isset($params['dbname'])) { + $dsn .= 'dbname=' . $params['dbname'] . ';'; + } + + if (isset($params['unix_socket'])) { + $dsn .= 'unix_socket=' . $params['unix_socket'] . ';'; + } + + if (isset($params['charset'])) { + $dsn .= 'charset=' . $params['charset'] . ';'; + } + + return $dsn; + } +} diff --git a/vendor/doctrine/dbal/src/Driver/PDO/OCI/Driver.php b/vendor/doctrine/dbal/src/Driver/PDO/OCI/Driver.php new file mode 100644 index 0000000..4c02de1 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/PDO/OCI/Driver.php @@ -0,0 +1,61 @@ +constructPdoDsn($params), + $params['user'] ?? '', + $params['password'] ?? '', + $driverOptions, + ); + } catch (PDOException $exception) { + throw Exception::new($exception); + } + + return new Connection($pdo); + } + + /** + * Constructs the Oracle PDO DSN. + * + * @param mixed[] $params + */ + private function constructPdoDsn(array $params): string + { + $dsn = 'oci:dbname=' . $this->getEasyConnectString($params); + + if (isset($params['charset'])) { + $dsn .= ';charset=' . $params['charset']; + } + + return $dsn; + } +} diff --git a/vendor/doctrine/dbal/src/Driver/PDO/PgSQL/Driver.php b/vendor/doctrine/dbal/src/Driver/PDO/PgSQL/Driver.php new file mode 100644 index 0000000..a267e84 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/PDO/PgSQL/Driver.php @@ -0,0 +1,113 @@ +constructPdoDsn($safeParams), + $params['user'] ?? '', + $params['password'] ?? '', + $driverOptions, + ); + } catch (PDOException $exception) { + throw Exception::new($exception); + } + + if ( + ! isset($driverOptions[PDO::PGSQL_ATTR_DISABLE_PREPARES]) + || $driverOptions[PDO::PGSQL_ATTR_DISABLE_PREPARES] === true + ) { + $pdo->setAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES, true); + } + + $connection = new Connection($pdo); + + /* defining client_encoding via SET NAMES to avoid inconsistent DSN support + * - passing client_encoding via the 'options' param breaks pgbouncer support + */ + if (isset($params['charset'])) { + $connection->exec('SET NAMES \'' . $params['charset'] . '\''); + } + + return $connection; + } + + /** + * Constructs the Postgres PDO DSN. + * + * @param array $params + */ + private function constructPdoDsn(array $params): string + { + $dsn = 'pgsql:'; + + if (isset($params['host']) && $params['host'] !== '') { + $dsn .= 'host=' . $params['host'] . ';'; + } + + if (isset($params['port']) && $params['port'] !== '') { + $dsn .= 'port=' . $params['port'] . ';'; + } + + if (isset($params['dbname'])) { + $dsn .= 'dbname=' . $params['dbname'] . ';'; + } + + if (isset($params['sslmode'])) { + $dsn .= 'sslmode=' . $params['sslmode'] . ';'; + } + + if (isset($params['sslrootcert'])) { + $dsn .= 'sslrootcert=' . $params['sslrootcert'] . ';'; + } + + if (isset($params['sslcert'])) { + $dsn .= 'sslcert=' . $params['sslcert'] . ';'; + } + + if (isset($params['sslkey'])) { + $dsn .= 'sslkey=' . $params['sslkey'] . ';'; + } + + if (isset($params['sslcrl'])) { + $dsn .= 'sslcrl=' . $params['sslcrl'] . ';'; + } + + if (isset($params['application_name'])) { + $dsn .= 'application_name=' . $params['application_name'] . ';'; + } + + if (isset($params['gssencmode'])) { + $dsn .= 'gssencmode=' . $params['gssencmode'] . ';'; + } + + return $dsn; + } +} diff --git a/vendor/doctrine/dbal/src/Driver/PDO/Result.php b/vendor/doctrine/dbal/src/Driver/PDO/Result.php new file mode 100644 index 0000000..1a844d1 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/PDO/Result.php @@ -0,0 +1,110 @@ +fetch(PDO::FETCH_NUM); + } + + public function fetchAssociative(): array|false + { + return $this->fetch(PDO::FETCH_ASSOC); + } + + public function fetchOne(): mixed + { + return $this->fetch(PDO::FETCH_COLUMN); + } + + /** + * {@inheritDoc} + */ + public function fetchAllNumeric(): array + { + return $this->fetchAll(PDO::FETCH_NUM); + } + + /** + * {@inheritDoc} + */ + public function fetchAllAssociative(): array + { + return $this->fetchAll(PDO::FETCH_ASSOC); + } + + /** + * {@inheritDoc} + */ + public function fetchFirstColumn(): array + { + return $this->fetchAll(PDO::FETCH_COLUMN); + } + + public function rowCount(): int + { + try { + return $this->statement->rowCount(); + } catch (PDOException $exception) { + throw Exception::new($exception); + } + } + + public function columnCount(): int + { + try { + return $this->statement->columnCount(); + } catch (PDOException $exception) { + throw Exception::new($exception); + } + } + + public function free(): void + { + $this->statement->closeCursor(); + } + + /** + * @psalm-param PDO::FETCH_* $mode + * + * @throws Exception + */ + private function fetch(int $mode): mixed + { + try { + return $this->statement->fetch($mode); + } catch (PDOException $exception) { + throw Exception::new($exception); + } + } + + /** + * @psalm-param PDO::FETCH_* $mode + * + * @return list + * + * @throws Exception + */ + private function fetchAll(int $mode): array + { + try { + return $this->statement->fetchAll($mode); + } catch (PDOException $exception) { + throw Exception::new($exception); + } + } +} diff --git a/vendor/doctrine/dbal/src/Driver/PDO/SQLSrv/Connection.php b/vendor/doctrine/dbal/src/Driver/PDO/SQLSrv/Connection.php new file mode 100644 index 0000000..78ba7f8 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/PDO/SQLSrv/Connection.php @@ -0,0 +1,29 @@ +connection->prepare($sql), + ); + } + + public function getNativeConnection(): PDO + { + return $this->connection->getNativeConnection(); + } +} diff --git a/vendor/doctrine/dbal/src/Driver/PDO/SQLSrv/Driver.php b/vendor/doctrine/dbal/src/Driver/PDO/SQLSrv/Driver.php new file mode 100644 index 0000000..a3cae97 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/PDO/SQLSrv/Driver.php @@ -0,0 +1,108 @@ + $value) { + if (is_int($option)) { + $driverOptions[$option] = $value; + } else { + $dsnOptions[$option] = $value; + } + } + } + + if (! empty($params['persistent'])) { + $driverOptions[PDO::ATTR_PERSISTENT] = true; + } + + $safeParams = $params; + unset($safeParams['password']); + + try { + $pdo = new PDO( + $this->constructDsn($safeParams, $dsnOptions), + $params['user'] ?? '', + $params['password'] ?? '', + $driverOptions, + ); + } catch (\PDOException $exception) { + throw PDOException::new($exception); + } + + return new Connection(new PDOConnection($pdo)); + } + + /** + * Constructs the Sqlsrv PDO DSN. + * + * @param mixed[] $params + * @param string[] $connectionOptions + * + * @throws Exception + */ + private function constructDsn(array $params, array $connectionOptions): string + { + $dsn = 'sqlsrv:server='; + + if (isset($params['host'])) { + $dsn .= $params['host']; + + if (isset($params['port'])) { + $dsn .= ',' . $params['port']; + } + } elseif (isset($params['port'])) { + throw PortWithoutHost::new(); + } + + if (isset($params['dbname'])) { + $connectionOptions['Database'] = $params['dbname']; + } + + if (isset($params['MultipleActiveResultSets'])) { + $connectionOptions['MultipleActiveResultSets'] = $params['MultipleActiveResultSets'] ? 'true' : 'false'; + } + + return $dsn . $this->getConnectionOptionsDsn($connectionOptions); + } + + /** + * Converts a connection options array to the DSN + * + * @param string[] $connectionOptions + */ + private function getConnectionOptionsDsn(array $connectionOptions): string + { + $connectionOptionsDsn = ''; + + foreach ($connectionOptions as $paramName => $paramValue) { + $connectionOptionsDsn .= sprintf(';%s=%s', $paramName, $paramValue); + } + + return $connectionOptionsDsn; + } +} diff --git a/vendor/doctrine/dbal/src/Driver/PDO/SQLSrv/Statement.php b/vendor/doctrine/dbal/src/Driver/PDO/SQLSrv/Statement.php new file mode 100644 index 0000000..44cecc9 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/PDO/SQLSrv/Statement.php @@ -0,0 +1,46 @@ +statement->bindParamWithDriverOptions( + $param, + $value, + $type, + PDO::SQLSRV_ENCODING_BINARY, + ); + break; + + case ParameterType::ASCII: + $this->statement->bindParamWithDriverOptions( + $param, + $value, + ParameterType::STRING, + PDO::SQLSRV_ENCODING_SYSTEM, + ); + break; + + default: + $this->statement->bindValue($param, $value, $type); + } + } +} diff --git a/vendor/doctrine/dbal/src/Driver/PDO/SQLite/Driver.php b/vendor/doctrine/dbal/src/Driver/PDO/SQLite/Driver.php new file mode 100644 index 0000000..74194a5 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/PDO/SQLite/Driver.php @@ -0,0 +1,55 @@ +constructPdoDsn(array_intersect_key($params, ['path' => true, 'memory' => true])), + $params['user'] ?? '', + $params['password'] ?? '', + $params['driverOptions'] ?? [], + ); + } catch (PDOException $exception) { + throw Exception::new($exception); + } + + return new Connection($pdo); + } + + /** + * Constructs the Sqlite PDO DSN. + * + * @param array $params + */ + private function constructPdoDsn(array $params): string + { + $dsn = 'sqlite:'; + if (isset($params['path'])) { + $dsn .= $params['path']; + } elseif (isset($params['memory'])) { + $dsn .= ':memory:'; + } + + return $dsn; + } +} diff --git a/vendor/doctrine/dbal/src/Driver/PDO/Statement.php b/vendor/doctrine/dbal/src/Driver/PDO/Statement.php new file mode 100644 index 0000000..4f0e070 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/PDO/Statement.php @@ -0,0 +1,80 @@ +convertParamType($type); + + try { + $this->stmt->bindValue($param, $value, $pdoType); + } catch (PDOException $exception) { + throw Exception::new($exception); + } + } + + /** + * @internal Driver options can be only specified by a PDO-based driver. + * + * @throws ExceptionInterface + */ + public function bindParamWithDriverOptions( + string|int $param, + mixed &$variable, + ParameterType $type, + mixed $driverOptions, + ): void { + $pdoType = $this->convertParamType($type); + + try { + $this->stmt->bindParam($param, $variable, $pdoType, 0, $driverOptions); + } catch (PDOException $exception) { + throw Exception::new($exception); + } + } + + public function execute(): Result + { + try { + $this->stmt->execute(); + } catch (PDOException $exception) { + throw Exception::new($exception); + } + + return new Result($this->stmt); + } + + /** + * Converts DBAL parameter type to PDO parameter type + * + * @psalm-return PDO::PARAM_* + */ + private function convertParamType(ParameterType $type): int + { + return match ($type) { + ParameterType::NULL => PDO::PARAM_NULL, + ParameterType::INTEGER => PDO::PARAM_INT, + ParameterType::STRING, + ParameterType::ASCII => PDO::PARAM_STR, + ParameterType::BINARY, + ParameterType::LARGE_OBJECT => PDO::PARAM_LOB, + ParameterType::BOOLEAN => PDO::PARAM_BOOL, + }; + } +} diff --git a/vendor/doctrine/dbal/src/Driver/PgSQL/Connection.php b/vendor/doctrine/dbal/src/Driver/PgSQL/Connection.php new file mode 100644 index 0000000..4f280b0 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/PgSQL/Connection.php @@ -0,0 +1,129 @@ +parser = new Parser(false); + } + + public function __destruct() + { + if (! isset($this->connection)) { + return; + } + + @pg_close($this->connection); + } + + public function prepare(string $sql): Statement + { + $visitor = new ConvertParameters(); + $this->parser->parse($sql, $visitor); + + $statementName = uniqid('dbal', true); + if (@pg_send_prepare($this->connection, $statementName, $visitor->getSQL()) !== true) { + throw new Exception(pg_last_error($this->connection)); + } + + $result = @pg_get_result($this->connection); + assert($result !== false); + + if ((bool) pg_result_error($result)) { + throw Exception::fromResult($result); + } + + return new Statement($this->connection, $statementName, $visitor->getParameterMap()); + } + + public function query(string $sql): Result + { + if (@pg_send_query($this->connection, $sql) !== true) { + throw new Exception(pg_last_error($this->connection)); + } + + $result = @pg_get_result($this->connection); + assert($result !== false); + + if ((bool) pg_result_error($result)) { + throw Exception::fromResult($result); + } + + return new Result($result); + } + + /** {@inheritDoc} */ + public function quote(string $value): string + { + $quotedValue = pg_escape_literal($this->connection, $value); + assert($quotedValue !== false); + + return $quotedValue; + } + + public function exec(string $sql): int + { + return $this->query($sql)->rowCount(); + } + + /** {@inheritDoc} */ + public function lastInsertId(): int|string + { + try { + return $this->query('SELECT LASTVAL()')->fetchOne(); + } catch (Exception $exception) { + if ($exception->getSQLState() === '55000') { + throw NoIdentityValue::new($exception); + } + + throw $exception; + } + } + + public function beginTransaction(): void + { + $this->exec('BEGIN'); + } + + public function commit(): void + { + $this->exec('COMMIT'); + } + + public function rollBack(): void + { + $this->exec('ROLLBACK'); + } + + public function getServerVersion(): string + { + return (string) pg_version($this->connection)['server']; + } + + public function getNativeConnection(): PgSqlConnection + { + return $this->connection; + } +} diff --git a/vendor/doctrine/dbal/src/Driver/PgSQL/ConvertParameters.php b/vendor/doctrine/dbal/src/Driver/PgSQL/ConvertParameters.php new file mode 100644 index 0000000..795f12d --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/PgSQL/ConvertParameters.php @@ -0,0 +1,49 @@ + */ + private array $buffer = []; + + /** @var array */ + private array $parameterMap = []; + + public function acceptPositionalParameter(string $sql): void + { + $position = count($this->parameterMap) + 1; + $this->parameterMap[$position] = $position; + $this->buffer[] = '$' . $position; + } + + public function acceptNamedParameter(string $sql): void + { + $position = count($this->parameterMap) + 1; + $this->parameterMap[$sql] = $position; + $this->buffer[] = '$' . $position; + } + + public function acceptOther(string $sql): void + { + $this->buffer[] = $sql; + } + + public function getSQL(): string + { + return implode('', $this->buffer); + } + + /** @return array */ + public function getParameterMap(): array + { + return $this->parameterMap; + } +} diff --git a/vendor/doctrine/dbal/src/Driver/PgSQL/Driver.php b/vendor/doctrine/dbal/src/Driver/PgSQL/Driver.php new file mode 100644 index 0000000..0d5d605 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/PgSQL/Driver.php @@ -0,0 +1,88 @@ +constructConnectionString($params), PGSQL_CONNECT_FORCE_NEW); + } catch (ErrorException $e) { + throw new Exception($e->getMessage(), '08006', 0, $e); + } finally { + restore_error_handler(); + } + + if ($connection === false) { + throw new Exception('Unable to connect to Postgres server.'); + } + + $driverConnection = new Connection($connection); + + if (isset($params['application_name'])) { + $driverConnection->exec('SET application_name = ' . $driverConnection->quote($params['application_name'])); + } + + return $driverConnection; + } + + /** + * Constructs the Postgres connection string + * + * @param array $params + */ + private function constructConnectionString( + #[SensitiveParameter] + array $params, + ): string { + $components = array_filter( + [ + 'host' => $params['host'] ?? null, + 'port' => $params['port'] ?? null, + 'dbname' => $params['dbname'] ?? 'postgres', + 'user' => $params['user'] ?? null, + 'password' => $params['password'] ?? null, + 'sslmode' => $params['sslmode'] ?? null, + 'gssencmode' => $params['gssencmode'] ?? null, + ], + static fn (int|string|null $value) => $value !== '' && $value !== null, + ); + + return implode(' ', array_map( + static fn (int|string $value, string $key) => sprintf("%s='%s'", $key, addslashes((string) $value)), + array_values($components), + array_keys($components), + )); + } +} diff --git a/vendor/doctrine/dbal/src/Driver/PgSQL/Exception.php b/vendor/doctrine/dbal/src/Driver/PgSQL/Exception.php new file mode 100644 index 0000000..3036e55 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/PgSQL/Exception.php @@ -0,0 +1,31 @@ +result = $result; + } + + public function __destruct() + { + if (! isset($this->result)) { + return; + } + + $this->free(); + } + + /** {@inheritDoc} */ + public function fetchNumeric(): array|false + { + if ($this->result === null) { + return false; + } + + $row = pg_fetch_row($this->result); + if ($row === false) { + return false; + } + + return $this->mapNumericRow($row, $this->fetchNumericColumnTypes()); + } + + /** {@inheritDoc} */ + public function fetchAssociative(): array|false + { + if ($this->result === null) { + return false; + } + + $row = pg_fetch_assoc($this->result); + if ($row === false) { + return false; + } + + return $this->mapAssociativeRow($row, $this->fetchAssociativeColumnTypes()); + } + + /** {@inheritDoc} */ + public function fetchOne(): mixed + { + return FetchUtils::fetchOne($this); + } + + /** {@inheritDoc} */ + public function fetchAllNumeric(): array + { + if ($this->result === null) { + return []; + } + + $types = $this->fetchNumericColumnTypes(); + + return array_map( + fn (array $row) => $this->mapNumericRow($row, $types), + pg_fetch_all($this->result, PGSQL_NUM), + ); + } + + /** {@inheritDoc} */ + public function fetchAllAssociative(): array + { + if ($this->result === null) { + return []; + } + + $types = $this->fetchAssociativeColumnTypes(); + + return array_map( + fn (array $row) => $this->mapAssociativeRow($row, $types), + pg_fetch_all($this->result, PGSQL_ASSOC), + ); + } + + /** {@inheritDoc} */ + public function fetchFirstColumn(): array + { + if ($this->result === null) { + return []; + } + + $postgresType = pg_field_type($this->result, 0); + + return array_map( + fn ($value) => $this->mapType($postgresType, $value), + pg_fetch_all_columns($this->result), + ); + } + + public function rowCount(): int + { + if ($this->result === null) { + return 0; + } + + return pg_affected_rows($this->result); + } + + public function columnCount(): int + { + if ($this->result === null) { + return 0; + } + + return pg_num_fields($this->result); + } + + public function free(): void + { + if ($this->result === null) { + return; + } + + pg_free_result($this->result); + $this->result = null; + } + + /** @return array */ + private function fetchNumericColumnTypes(): array + { + assert($this->result !== null); + + $types = []; + $numFields = pg_num_fields($this->result); + for ($i = 0; $i < $numFields; ++$i) { + $types[$i] = pg_field_type($this->result, $i); + } + + return $types; + } + + /** @return array */ + private function fetchAssociativeColumnTypes(): array + { + assert($this->result !== null); + + $types = []; + $numFields = pg_num_fields($this->result); + for ($i = 0; $i < $numFields; ++$i) { + $types[pg_field_name($this->result, $i)] = pg_field_type($this->result, $i); + } + + return $types; + } + + /** + * @param list $row + * @param array $types + * + * @return list + */ + private function mapNumericRow(array $row, array $types): array + { + assert($this->result !== null); + + return array_map( + fn ($value, $field) => $this->mapType($types[$field], $value), + $row, + array_keys($row), + ); + } + + /** + * @param array $row + * @param array $types + * + * @return array + */ + private function mapAssociativeRow(array $row, array $types): array + { + assert($this->result !== null); + + $mappedRow = []; + foreach ($row as $field => $value) { + $mappedRow[$field] = $this->mapType($types[$field], $value); + } + + return $mappedRow; + } + + private function mapType(string $postgresType, ?string $value): string|int|float|bool|null + { + if ($value === null) { + return null; + } + + return match ($postgresType) { + 'bool' => match ($value) { + 't' => true, + 'f' => false, + default => throw UnexpectedValue::new($value, $postgresType), + }, + 'bytea' => hex2bin(substr($value, 2)), + 'float4', 'float8' => (float) $value, + 'int2', 'int4' => (int) $value, + 'int8' => PHP_INT_SIZE >= 8 ? (int) $value : $value, + default => $value, + }; + } +} diff --git a/vendor/doctrine/dbal/src/Driver/PgSQL/Statement.php b/vendor/doctrine/dbal/src/Driver/PgSQL/Statement.php new file mode 100644 index 0000000..b48ab5d --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/PgSQL/Statement.php @@ -0,0 +1,91 @@ + */ + private array $parameters = []; + + /** @psalm-var array */ + private array $parameterTypes = []; + + /** @param array $parameterMap */ + public function __construct( + private readonly PgSqlConnection $connection, + private readonly string $name, + private readonly array $parameterMap, + ) { + } + + public function __destruct() + { + if (! isset($this->connection)) { + return; + } + + @pg_query( + $this->connection, + 'DEALLOCATE ' . pg_escape_identifier($this->connection, $this->name), + ); + } + + /** {@inheritDoc} */ + public function bindValue(int|string $param, mixed $value, ParameterType $type = ParameterType::STRING): void + { + if (! isset($this->parameterMap[$param])) { + throw UnknownParameter::new((string) $param); + } + + $this->parameters[$this->parameterMap[$param]] = $value; + $this->parameterTypes[$this->parameterMap[$param]] = $type; + } + + /** {@inheritDoc} */ + public function execute(): Result + { + ksort($this->parameters); + + $escapedParameters = []; + foreach ($this->parameters as $parameter => $value) { + $escapedParameters[] = match ($this->parameterTypes[$parameter]) { + ParameterType::BINARY, ParameterType::LARGE_OBJECT => $value === null + ? null + : pg_escape_bytea($this->connection, is_resource($value) ? stream_get_contents($value) : $value), + default => $value, + }; + } + + if (@pg_send_execute($this->connection, $this->name, $escapedParameters) !== true) { + throw new Exception(pg_last_error($this->connection)); + } + + $result = @pg_get_result($this->connection); + assert($result !== false); + + if ((bool) pg_result_error($result)) { + throw Exception::fromResult($result); + } + + return new Result($result); + } +} diff --git a/vendor/doctrine/dbal/src/Driver/Result.php b/vendor/doctrine/dbal/src/Driver/Result.php new file mode 100644 index 0000000..500cb88 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/Result.php @@ -0,0 +1,93 @@ +|false + * + * @throws Exception + */ + public function fetchNumeric(): array|false; + + /** + * Returns the next row of the result as an associative array or FALSE if there are no more rows. + * + * @return array|false + * + * @throws Exception + */ + public function fetchAssociative(): array|false; + + /** + * Returns the first value of the next row of the result or FALSE if there are no more rows. + * + * @throws Exception + */ + public function fetchOne(): mixed; + + /** + * Returns an array containing all of the result rows represented as numeric arrays. + * + * @return list> + * + * @throws Exception + */ + public function fetchAllNumeric(): array; + + /** + * Returns an array containing all of the result rows represented as associative arrays. + * + * @return list> + * + * @throws Exception + */ + public function fetchAllAssociative(): array; + + /** + * Returns an array containing the values of the first column of the result. + * + * @return list + * + * @throws Exception + */ + public function fetchFirstColumn(): array; + + /** + * Returns the number of rows affected by the DELETE, INSERT, or UPDATE statement that produced the result. + * + * If the statement executed a SELECT query or a similar platform-specific SQL (e.g. DESCRIBE, SHOW, etc.), + * some database drivers may return the number of rows returned by that query. However, this behaviour + * is not guaranteed for all drivers and should not be relied on in portable applications. + * + * If the number of rows exceeds {@see PHP_INT_MAX}, it might be returned as string if the driver supports it. + * + * @return int|numeric-string + * + * @throws Exception + */ + public function rowCount(): int|string; + + /** + * Returns the number of columns in the result + * + * @return int The number of columns in the result. If the columns cannot be counted, + * this method must return 0. + * + * @throws Exception + */ + public function columnCount(): int; + + /** + * Discards the non-fetched portion of the result, enabling the originating statement to be executed again. + */ + public function free(): void; +} diff --git a/vendor/doctrine/dbal/src/Driver/SQLSrv/Connection.php b/vendor/doctrine/dbal/src/Driver/SQLSrv/Connection.php new file mode 100644 index 0000000..71050f1 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/SQLSrv/Connection.php @@ -0,0 +1,108 @@ +connection); + + return $serverInfo['SQLServerVersion']; + } + + public function prepare(string $sql): Statement + { + return new Statement($this->connection, $sql); + } + + public function query(string $sql): Result + { + return $this->prepare($sql)->execute(); + } + + public function quote(string $value): string + { + return "'" . str_replace("'", "''", $value) . "'"; + } + + public function exec(string $sql): int + { + $stmt = sqlsrv_query($this->connection, $sql); + + if ($stmt === false) { + throw Error::new(); + } + + $rowsAffected = sqlsrv_rows_affected($stmt); + + if ($rowsAffected === false) { + throw Error::new(); + } + + return $rowsAffected; + } + + public function lastInsertId(): int|string + { + $result = $this->query('SELECT @@IDENTITY'); + + $lastInsertId = $result->fetchOne(); + + if ($lastInsertId === null) { + throw NoIdentityValue::new(); + } + + return $lastInsertId; + } + + public function beginTransaction(): void + { + if (! sqlsrv_begin_transaction($this->connection)) { + throw Error::new(); + } + } + + public function commit(): void + { + if (! sqlsrv_commit($this->connection)) { + throw Error::new(); + } + } + + public function rollBack(): void + { + if (! sqlsrv_rollback($this->connection)) { + throw Error::new(); + } + } + + /** @return resource */ + public function getNativeConnection() + { + return $this->connection; + } +} diff --git a/vendor/doctrine/dbal/src/Driver/SQLSrv/Driver.php b/vendor/doctrine/dbal/src/Driver/SQLSrv/Driver.php new file mode 100644 index 0000000..c9c2c34 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/SQLSrv/Driver.php @@ -0,0 +1,73 @@ +fetch(SQLSRV_FETCH_NUMERIC); + } + + public function fetchAssociative(): array|false + { + return $this->fetch(SQLSRV_FETCH_ASSOC); + } + + public function fetchOne(): mixed + { + return FetchUtils::fetchOne($this); + } + + /** + * {@inheritDoc} + */ + public function fetchAllNumeric(): array + { + return FetchUtils::fetchAllNumeric($this); + } + + /** + * {@inheritDoc} + */ + public function fetchAllAssociative(): array + { + return FetchUtils::fetchAllAssociative($this); + } + + /** + * {@inheritDoc} + */ + public function fetchFirstColumn(): array + { + return FetchUtils::fetchFirstColumn($this); + } + + public function rowCount(): int + { + $count = sqlsrv_rows_affected($this->statement); + + if ($count !== false) { + return $count; + } + + return 0; + } + + public function columnCount(): int + { + $count = sqlsrv_num_fields($this->statement); + + if ($count !== false) { + return $count; + } + + return 0; + } + + public function free(): void + { + // emulate it by fetching and discarding rows, similarly to what PDO does in this case + // @link http://php.net/manual/en/pdostatement.closecursor.php + // @link https://github.com/php/php-src/blob/php-7.0.11/ext/pdo/pdo_stmt.c#L2075 + // deliberately do not consider multiple result sets, since doctrine/dbal doesn't support them + while (sqlsrv_fetch($this->statement)) { + } + } + + private function fetch(int $fetchType): mixed + { + return sqlsrv_fetch_array($this->statement, $fetchType) ?? false; + } +} diff --git a/vendor/doctrine/dbal/src/Driver/SQLSrv/Statement.php b/vendor/doctrine/dbal/src/Driver/SQLSrv/Statement.php new file mode 100644 index 0000000..dc7827a --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/SQLSrv/Statement.php @@ -0,0 +1,140 @@ + + */ + private array $variables = []; + + /** + * Bound parameter types. + * + * @var array + */ + private array $types = []; + + /** + * Append to any INSERT query to retrieve the last insert id. + */ + private const LAST_INSERT_ID_SQL = ';SELECT SCOPE_IDENTITY() AS LastInsertId;'; + + /** + * @internal The statement can be only instantiated by its driver connection. + * + * @param resource $conn + */ + public function __construct( + private readonly mixed $conn, + private string $sql, + ) { + if (stripos($sql, 'INSERT INTO ') !== 0) { + return; + } + + $this->sql .= self::LAST_INSERT_ID_SQL; + } + + public function bindValue(int|string $param, mixed $value, ParameterType $type): void + { + assert(is_int($param)); + + $this->variables[$param] = $value; + $this->types[$param] = $type; + } + + public function execute(): Result + { + $this->stmt ??= $this->prepare(); + + if (! sqlsrv_execute($this->stmt)) { + throw Error::new(); + } + + return new Result($this->stmt); + } + + /** + * Prepares SQL Server statement resource + * + * @return resource + * + * @throws Exception + */ + private function prepare() + { + $params = []; + + foreach ($this->variables as $column => &$variable) { + switch ($this->types[$column]) { + case ParameterType::LARGE_OBJECT: + $params[$column - 1] = [ + &$variable, + SQLSRV_PARAM_IN, + SQLSRV_PHPTYPE_STREAM(SQLSRV_ENC_BINARY), + SQLSRV_SQLTYPE_VARBINARY('max'), + ]; + break; + + case ParameterType::BINARY: + $params[$column - 1] = [ + &$variable, + SQLSRV_PARAM_IN, + SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_BINARY), + ]; + break; + + case ParameterType::ASCII: + $params[$column - 1] = [ + &$variable, + SQLSRV_PARAM_IN, + SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_CHAR), + ]; + break; + + default: + $params[$column - 1] =& $variable; + break; + } + } + + $stmt = sqlsrv_prepare($this->conn, $this->sql, $params); + + if ($stmt === false) { + throw Error::new(); + } + + return $stmt; + } +} diff --git a/vendor/doctrine/dbal/src/Driver/SQLite3/Connection.php b/vendor/doctrine/dbal/src/Driver/SQLite3/Connection.php new file mode 100644 index 0000000..1e9af93 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/SQLite3/Connection.php @@ -0,0 +1,109 @@ +connection->prepare($sql); + } catch (\Exception $e) { + throw Exception::new($e); + } + + assert($statement !== false); + + return new Statement($this->connection, $statement); + } + + public function query(string $sql): Result + { + try { + $result = $this->connection->query($sql); + } catch (\Exception $e) { + throw Exception::new($e); + } + + assert($result !== false); + + return new Result($result, $this->connection->changes()); + } + + public function quote(string $value): string + { + return sprintf('\'%s\'', SQLite3::escapeString($value)); + } + + public function exec(string $sql): int + { + try { + $this->connection->exec($sql); + } catch (\Exception $e) { + throw Exception::new($e); + } + + return $this->connection->changes(); + } + + public function lastInsertId(): int + { + $value = $this->connection->lastInsertRowID(); + if ($value === 0) { + throw NoIdentityValue::new(); + } + + return $value; + } + + public function beginTransaction(): void + { + try { + $this->connection->exec('BEGIN'); + } catch (\Exception $e) { + throw Exception::new($e); + } + } + + public function commit(): void + { + try { + $this->connection->exec('COMMIT'); + } catch (\Exception $e) { + throw Exception::new($e); + } + } + + public function rollBack(): void + { + try { + $this->connection->exec('ROLLBACK'); + } catch (\Exception $e) { + throw Exception::new($e); + } + } + + public function getNativeConnection(): SQLite3 + { + return $this->connection; + } + + public function getServerVersion(): string + { + return SQLite3::version()['versionString']; + } +} diff --git a/vendor/doctrine/dbal/src/Driver/SQLite3/Driver.php b/vendor/doctrine/dbal/src/Driver/SQLite3/Driver.php new file mode 100644 index 0000000..e6996d3 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/SQLite3/Driver.php @@ -0,0 +1,48 @@ +enableExceptions(true); + + return new Connection($connection); + } +} diff --git a/vendor/doctrine/dbal/src/Driver/SQLite3/Exception.php b/vendor/doctrine/dbal/src/Driver/SQLite3/Exception.php new file mode 100644 index 0000000..d423004 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/SQLite3/Exception.php @@ -0,0 +1,20 @@ +getMessage(), null, (int) $exception->getCode(), $exception); + } +} diff --git a/vendor/doctrine/dbal/src/Driver/SQLite3/Result.php b/vendor/doctrine/dbal/src/Driver/SQLite3/Result.php new file mode 100644 index 0000000..61b42d3 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/SQLite3/Result.php @@ -0,0 +1,88 @@ +result = $result; + } + + public function fetchNumeric(): array|false + { + if ($this->result === null) { + return false; + } + + return $this->result->fetchArray(SQLITE3_NUM); + } + + public function fetchAssociative(): array|false + { + if ($this->result === null) { + return false; + } + + return $this->result->fetchArray(SQLITE3_ASSOC); + } + + public function fetchOne(): mixed + { + return FetchUtils::fetchOne($this); + } + + /** @inheritDoc */ + public function fetchAllNumeric(): array + { + return FetchUtils::fetchAllNumeric($this); + } + + /** @inheritDoc */ + public function fetchAllAssociative(): array + { + return FetchUtils::fetchAllAssociative($this); + } + + /** @inheritDoc */ + public function fetchFirstColumn(): array + { + return FetchUtils::fetchFirstColumn($this); + } + + public function rowCount(): int + { + return $this->changes; + } + + public function columnCount(): int + { + if ($this->result === null) { + return 0; + } + + return $this->result->numColumns(); + } + + public function free(): void + { + if ($this->result === null) { + return; + } + + $this->result->finalize(); + $this->result = null; + } +} diff --git a/vendor/doctrine/dbal/src/Driver/SQLite3/Statement.php b/vendor/doctrine/dbal/src/Driver/SQLite3/Statement.php new file mode 100644 index 0000000..fe22e1d --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/SQLite3/Statement.php @@ -0,0 +1,61 @@ +statement->bindValue($param, $value, $this->convertParamType($type)); + } + + public function execute(): Result + { + try { + $result = $this->statement->execute(); + } catch (\Exception $e) { + throw Exception::new($e); + } + + assert($result !== false); + + return new Result($result, $this->connection->changes()); + } + + /** @psalm-return self::TYPE_* */ + private function convertParamType(ParameterType $type): int + { + return match ($type) { + ParameterType::NULL => self::TYPE_NULL, + ParameterType::INTEGER, ParameterType::BOOLEAN => self::TYPE_INTEGER, + ParameterType::STRING, ParameterType::ASCII => self::TYPE_TEXT, + ParameterType::BINARY, ParameterType::LARGE_OBJECT => self::TYPE_BLOB, + }; + } +} diff --git a/vendor/doctrine/dbal/src/Driver/Statement.php b/vendor/doctrine/dbal/src/Driver/Statement.php new file mode 100644 index 0000000..5f91b49 --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/Statement.php @@ -0,0 +1,39 @@ +