vendor/doctrine/dbal/src/Driver/AbstractPostgreSQLDriver.php line 60

Open in your IDE?
  1. <?php
  2. namespace Doctrine\DBAL\Driver;
  3. use Doctrine\DBAL\Connection;
  4. use Doctrine\DBAL\Driver\API\ExceptionConverter;
  5. use Doctrine\DBAL\Driver\API\PostgreSQL;
  6. use Doctrine\DBAL\Exception;
  7. use Doctrine\DBAL\Platforms\AbstractPlatform;
  8. use Doctrine\DBAL\Platforms\PostgreSQL100Platform;
  9. use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
  10. use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
  11. use Doctrine\DBAL\Schema\PostgreSQLSchemaManager;
  12. use Doctrine\DBAL\VersionAwarePlatformDriver;
  13. use Doctrine\Deprecations\Deprecation;
  14. use function assert;
  15. use function preg_match;
  16. use function version_compare;
  17. /**
  18.  * Abstract base implementation of the {@see Driver} interface for PostgreSQL based drivers.
  19.  */
  20. abstract class AbstractPostgreSQLDriver implements VersionAwarePlatformDriver
  21. {
  22.     /**
  23.      * {@inheritdoc}
  24.      */
  25.     public function createDatabasePlatformForVersion($version)
  26.     {
  27.         if (preg_match('/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+))?)?/'$version$versionParts) === 0) {
  28.             throw Exception::invalidPlatformVersionSpecified(
  29.                 $version,
  30.                 '<major_version>.<minor_version>.<patch_version>'
  31.             );
  32.         }
  33.         $majorVersion $versionParts['major'];
  34.         $minorVersion $versionParts['minor'] ?? 0;
  35.         $patchVersion $versionParts['patch'] ?? 0;
  36.         $version      $majorVersion '.' $minorVersion '.' $patchVersion;
  37.         if (version_compare($version'10.0''>=')) {
  38.             return new PostgreSQL100Platform();
  39.         }
  40.         Deprecation::trigger(
  41.             'doctrine/dbal',
  42.             'https://github.com/doctrine/dbal/pull/5060',
  43.             'PostgreSQL 9 support is deprecated and will be removed in DBAL 4.'
  44.                 ' Consider upgrading to Postgres 10 or later.'
  45.         );
  46.         return new PostgreSQL94Platform();
  47.     }
  48.     /**
  49.      * {@inheritdoc}
  50.      */
  51.     public function getDatabasePlatform()
  52.     {
  53.         return new PostgreSQL94Platform();
  54.     }
  55.     /**
  56.      * {@inheritdoc}
  57.      */
  58.     public function getSchemaManager(Connection $connAbstractPlatform $platform)
  59.     {
  60.         assert($platform instanceof PostgreSQLPlatform);
  61.         return new PostgreSQLSchemaManager($conn$platform);
  62.     }
  63.     public function getExceptionConverter(): ExceptionConverter
  64.     {
  65.         return new PostgreSQL\ExceptionConverter();
  66.     }
  67. }