14
14
use Doctrine \DBAL \Configuration ;
15
15
use Doctrine \DBAL \Connection ;
16
16
use Doctrine \DBAL \DriverManager ;
17
+ use Doctrine \DBAL \Exception ;
17
18
use Doctrine \DBAL \Exception as DBALException ;
18
19
use Doctrine \DBAL \Exception \TableNotFoundException ;
19
20
use Doctrine \DBAL \ParameterType ;
@@ -242,9 +243,16 @@ private function getCurrentTimestampStatement(): string
242
243
{
243
244
$ platform = $ this ->conn ->getDatabasePlatform ();
244
245
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
+
245
253
return match (true ) {
246
254
$ 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 \') ' ,
248
256
$ platform instanceof \Doctrine \DBAL \Platforms \PostgreSQLPlatform => 'CAST(EXTRACT(epoch FROM NOW()) AS INT) ' ,
249
257
$ platform instanceof \Doctrine \DBAL \Platforms \OraclePlatform => '(SYSDATE - TO_DATE( \'19700101 \', \'yyyymmdd \'))*86400 - TO_NUMBER(SUBSTR(TZ_OFFSET(sessiontimezone), 1, 3))*3600 ' ,
250
258
$ platform instanceof \Doctrine \DBAL \Platforms \SQLServerPlatform => 'DATEDIFF(s, \'1970-01-01 \', GETUTCDATE()) ' ,
@@ -259,9 +267,16 @@ private function platformSupportsTableCreationInTransaction(): bool
259
267
{
260
268
$ platform = $ this ->conn ->getDatabasePlatform ();
261
269
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
+
262
277
return match (true ) {
263
278
$ platform instanceof \Doctrine \DBAL \Platforms \PostgreSQLPlatform,
264
- $ platform instanceof \ Doctrine \ DBAL \ Platforms \SqlitePlatform ,
279
+ $ platform instanceof $ sqlitePlatformClass ,
265
280
$ platform instanceof \Doctrine \DBAL \Platforms \SQLServerPlatform => true ,
266
281
default => false ,
267
282
};
0 commit comments