55use Doctrine \DBAL \Driver \AbstractPostgreSQLDriver ;
66use Doctrine \DBAL \Driver \PDO \Connection ;
77use Doctrine \DBAL \Driver \PDO \Exception ;
8+ use Doctrine \DBAL \Driver \PDO \PDOConnect ;
89use Doctrine \Deprecations \Deprecation ;
910use PDO ;
11+ use Pdo \Pgsql ;
1012use PDOException ;
1113use SensitiveParameter ;
1214
15+ use const PHP_VERSION_ID ;
16+
1317final class Driver extends AbstractPostgreSQLDriver
1418{
19+ use PDOConnect;
20+
1521 /**
1622 * {@inheritDoc}
1723 *
@@ -31,7 +37,7 @@ public function connect(
3137 unset($ safeParams ['password ' ], $ safeParams ['url ' ]);
3238
3339 try {
34- $ pdo = new PDO (
40+ $ pdo = $ this -> doConnect (
3541 $ this ->constructPdoDsn ($ safeParams ),
3642 $ params ['user ' ] ?? '' ,
3743 $ params ['password ' ] ?? '' ,
@@ -41,11 +47,11 @@ public function connect(
4147 throw Exception::new ($ exception );
4248 }
4349
44- if (
45- ! isset ( $ driverOptions [ PDO :: PGSQL_ATTR_DISABLE_PREPARES ])
46- || $ driverOptions [ PDO ::PGSQL_ATTR_DISABLE_PREPARES ] === true
47- ) {
48- $ pdo ->setAttribute (PDO :: PGSQL_ATTR_DISABLE_PREPARES , true );
50+ $ disablePreparesAttr = PHP_VERSION_ID >= 80400
51+ ? Pgsql:: ATTR_DISABLE_PREPARES
52+ : PDO ::PGSQL_ATTR_DISABLE_PREPARES ;
53+ if ( $ driverOptions [ $ disablePreparesAttr ] ?? true ) {
54+ $ pdo ->setAttribute ($ disablePreparesAttr , true );
4955 }
5056
5157 $ connection = new Connection ($ pdo );
0 commit comments