diff options
| author | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
| commit | bf6655a534a6775d30cafa67bd801276bda1d98d (patch) | |
| tree | c6381e3f6c81c33eab72508f410b165ba05f7e9c /vendor/doctrine/dbal/src/Driver/AbstractMySQLDriver.php | |
| parent | 94d67a4b51f8e62e7d518cce26a526ae1ec48278 (diff) | |
| download | AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.tar.gz AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.tar.bz2 AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.zip | |
VERSION 0.2 doctrine ORM et entités
Diffstat (limited to 'vendor/doctrine/dbal/src/Driver/AbstractMySQLDriver.php')
| -rw-r--r-- | vendor/doctrine/dbal/src/Driver/AbstractMySQLDriver.php | 86 |
1 files changed, 86 insertions, 0 deletions
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 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | declare(strict_types=1); | ||
| 4 | |||
| 5 | namespace Doctrine\DBAL\Driver; | ||
| 6 | |||
| 7 | use Doctrine\DBAL\Driver; | ||
| 8 | use Doctrine\DBAL\Driver\API\ExceptionConverter as ExceptionConverterInterface; | ||
| 9 | use Doctrine\DBAL\Driver\API\MySQL\ExceptionConverter; | ||
| 10 | use Doctrine\DBAL\Platforms\AbstractMySQLPlatform; | ||
| 11 | use Doctrine\DBAL\Platforms\Exception\InvalidPlatformVersion; | ||
| 12 | use Doctrine\DBAL\Platforms\MariaDB1052Platform; | ||
| 13 | use Doctrine\DBAL\Platforms\MariaDB1060Platform; | ||
| 14 | use Doctrine\DBAL\Platforms\MariaDBPlatform; | ||
| 15 | use Doctrine\DBAL\Platforms\MySQL80Platform; | ||
| 16 | use Doctrine\DBAL\Platforms\MySQLPlatform; | ||
| 17 | use Doctrine\DBAL\ServerVersionProvider; | ||
| 18 | |||
| 19 | use function preg_match; | ||
| 20 | use function stripos; | ||
| 21 | use function version_compare; | ||
| 22 | |||
| 23 | /** | ||
| 24 | * Abstract base implementation of the {@see Driver} interface for MySQL based drivers. | ||
| 25 | */ | ||
| 26 | abstract class AbstractMySQLDriver implements Driver | ||
| 27 | { | ||
| 28 | /** | ||
| 29 | * {@inheritDoc} | ||
| 30 | * | ||
| 31 | * @throws InvalidPlatformVersion | ||
| 32 | */ | ||
| 33 | public function getDatabasePlatform(ServerVersionProvider $versionProvider): AbstractMySQLPlatform | ||
| 34 | { | ||
| 35 | $version = $versionProvider->getServerVersion(); | ||
| 36 | if (stripos($version, 'mariadb') !== false) { | ||
| 37 | $mariaDbVersion = $this->getMariaDbMysqlVersionNumber($version); | ||
| 38 | if (version_compare($mariaDbVersion, '10.6.0', '>=')) { | ||
| 39 | return new MariaDB1060Platform(); | ||
| 40 | } | ||
| 41 | |||
| 42 | if (version_compare($mariaDbVersion, '10.5.2', '>=')) { | ||
| 43 | return new MariaDB1052Platform(); | ||
| 44 | } | ||
| 45 | |||
| 46 | return new MariaDBPlatform(); | ||
| 47 | } | ||
| 48 | |||
| 49 | if (version_compare($version, '8.0.0', '>=')) { | ||
| 50 | return new MySQL80Platform(); | ||
| 51 | } | ||
| 52 | |||
| 53 | return new MySQLPlatform(); | ||
| 54 | } | ||
| 55 | |||
| 56 | public function getExceptionConverter(): ExceptionConverterInterface | ||
| 57 | { | ||
| 58 | return new ExceptionConverter(); | ||
| 59 | } | ||
| 60 | |||
| 61 | /** | ||
| 62 | * Detect MariaDB server version, including hack for some mariadb distributions | ||
| 63 | * that starts with the prefix '5.5.5-' | ||
| 64 | * | ||
| 65 | * @param string $versionString Version string as returned by mariadb server, i.e. '5.5.5-Mariadb-10.0.8-xenial' | ||
| 66 | * | ||
| 67 | * @throws InvalidPlatformVersion | ||
| 68 | */ | ||
| 69 | private function getMariaDbMysqlVersionNumber(string $versionString): string | ||
| 70 | { | ||
| 71 | if ( | ||
| 72 | preg_match( | ||
| 73 | '/^(?:5\.5\.5-)?(mariadb-)?(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)/i', | ||
| 74 | $versionString, | ||
| 75 | $versionParts, | ||
| 76 | ) === 0 | ||
| 77 | ) { | ||
| 78 | throw InvalidPlatformVersion::new( | ||
| 79 | $versionString, | ||
| 80 | '^(?:5\.5\.5-)?(mariadb-)?<major_version>.<minor_version>.<patch_version>', | ||
| 81 | ); | ||
| 82 | } | ||
| 83 | |||
| 84 | return $versionParts['major'] . '.' . $versionParts['minor'] . '.' . $versionParts['patch']; | ||
| 85 | } | ||
| 86 | } | ||
