2021-04-08 19:08:05 +02:00
|
|
|
<?php
|
|
|
|
|
2022-11-18 18:06:46 +01:00
|
|
|
namespace Core\Driver\SQL\Expression;
|
2021-04-08 19:08:05 +02:00
|
|
|
|
2023-01-05 22:47:17 +01:00
|
|
|
use Core\Driver\SQL\MySQL;
|
|
|
|
use Core\Driver\SQL\PostgreSQL;
|
|
|
|
use Core\Driver\SQL\SQL;
|
|
|
|
use Exception;
|
|
|
|
|
2021-04-08 19:08:05 +02:00
|
|
|
class CurrentTimeStamp extends Expression {
|
|
|
|
|
2023-01-05 22:47:17 +01:00
|
|
|
function getExpression(SQL $sql, array &$params): string {
|
|
|
|
if ($sql instanceof MySQL) {
|
|
|
|
return "NOW()";
|
|
|
|
} else if ($sql instanceof PostgreSQL) {
|
|
|
|
return "CURRENT_TIMESTAMP";
|
|
|
|
} else {
|
|
|
|
throw new Exception("CurrentTimeStamp Not implemented for driver type: " . get_class($sql));
|
|
|
|
}
|
|
|
|
}
|
2021-04-08 19:08:05 +02:00
|
|
|
}
|