function DoctrineDbalStore::getCurrentTimestampStatement
Provides an SQL function to get the current timestamp regarding the current connection's driver.
File
-
vendor/
symfony/ lock/ Store/ DoctrineDbalStore.php, line 233
Class
- DoctrineDbalStore
- DbalStore is a PersistingStoreInterface implementation using a Doctrine DBAL connection.
Namespace
Symfony\Component\Lock\StoreCode
private function getCurrentTimestampStatement() : string {
$platform = $this->conn
->getDatabasePlatform();
return match (true) { $platform instanceof \Doctrine\DBAL\Platforms\AbstractMySQLPlatform => 'UNIX_TIMESTAMP()',
$platform instanceof \Doctrine\DBAL\Platforms\SqlitePlatform => 'strftime(\'%s\',\'now\')',
$platform instanceof \Doctrine\DBAL\Platforms\PostgreSQLPlatform => 'CAST(EXTRACT(epoch FROM NOW()) AS INT)',
$platform instanceof \Doctrine\DBAL\Platforms\OraclePlatform => '(SYSDATE - TO_DATE(\'19700101\',\'yyyymmdd\'))*86400 - TO_NUMBER(SUBSTR(TZ_OFFSET(sessiontimezone), 1, 3))*3600',
$platform instanceof \Doctrine\DBAL\Platforms\SQLServerPlatform => 'DATEDIFF(s, \'1970-01-01\', GETUTCDATE())',
default => (string) time(),
};
}