1414use Doctrine \DBAL \Configuration ;
1515use Doctrine \DBAL \Connection ;
1616use Doctrine \DBAL \DriverManager ;
17+ use Doctrine \DBAL \Exception ;
1718use Doctrine \DBAL \Exception as DBALException ;
1819use Doctrine \DBAL \Exception \TableNotFoundException ;
1920use Doctrine \DBAL \ParameterType ;
@@ -242,9 +243,16 @@ private function getCurrentTimestampStatement(): string
242243 {
243244 $ platform = $ this ->conn ->getDatabasePlatform ();
244245
246+ if (interface_exists (Exception::class)) {
247+ // DBAL 4+
248+ $ sqlitePlatformClass = 'Doctrine\DBAL\Platforms\SQLitePlatform ' ;
249+ } else {
250+ $ sqlitePlatformClass = 'Doctrine\DBAL\Platforms\SqlitePlatform ' ;
251+ }
252+
245253 return match (true ) {
246254 $ platform instanceof \Doctrine \DBAL \Platforms \AbstractMySQLPlatform => 'UNIX_TIMESTAMP() ' ,
247- $ platform instanceof \ Doctrine \ DBAL \ Platforms \SqlitePlatform => 'strftime( \'%s \', \'now \') ' ,
255+ $ platform instanceof $ sqlitePlatformClass => 'strftime( \'%s \', \'now \') ' ,
248256 $ platform instanceof \Doctrine \DBAL \Platforms \PostgreSQLPlatform => 'CAST(EXTRACT(epoch FROM NOW()) AS INT) ' ,
249257 $ platform instanceof \Doctrine \DBAL \Platforms \OraclePlatform => '(SYSDATE - TO_DATE( \'19700101 \', \'yyyymmdd \'))*86400 - TO_NUMBER(SUBSTR(TZ_OFFSET(sessiontimezone), 1, 3))*3600 ' ,
250258 $ platform instanceof \Doctrine \DBAL \Platforms \SQLServerPlatform => 'DATEDIFF(s, \'1970-01-01 \', GETUTCDATE()) ' ,
@@ -259,9 +267,16 @@ private function platformSupportsTableCreationInTransaction(): bool
259267 {
260268 $ platform = $ this ->conn ->getDatabasePlatform ();
261269
270+ if (interface_exists (Exception::class)) {
271+ // DBAL 4+
272+ $ sqlitePlatformClass = 'Doctrine\DBAL\Platforms\SQLitePlatform ' ;
273+ } else {
274+ $ sqlitePlatformClass = 'Doctrine\DBAL\Platforms\SqlitePlatform ' ;
275+ }
276+
262277 return match (true ) {
263278 $ platform instanceof \Doctrine \DBAL \Platforms \PostgreSQLPlatform,
264- $ platform instanceof \ Doctrine \ DBAL \ Platforms \SqlitePlatform ,
279+ $ platform instanceof $ sqlitePlatformClass ,
265280 $ platform instanceof \Doctrine \DBAL \Platforms \SQLServerPlatform => true ,
266281 default => false ,
267282 };
0 commit comments