SQL expression rewrite, Pagination, some frontend stuff

This commit is contained in:
2023-01-05 22:47:17 +01:00
parent 4bfd6754cf
commit 99bfd7e505
61 changed files with 1745 additions and 570 deletions

View File

@@ -2,6 +2,12 @@
namespace Core\Driver\SQL\Expression;
use Core\Driver\SQL\Column\Column;
use Core\Driver\SQL\MySQL;
use Core\Driver\SQL\PostgreSQL;
use Core\Driver\SQL\SQL;
use Core\External\PHPMailer\Exception;
class DateAdd extends Expression {
private Expression $lhs;
@@ -18,4 +24,26 @@ class DateAdd extends Expression {
public function getRHS(): Expression { return $this->rhs; }
public function getUnit(): string { return $this->unit; }
function getExpression(SQL $sql, array &$params): string {
if ($sql instanceof MySQL) {
$lhs = $sql->addValue($this->getLHS(), $params);
$rhs = $sql->addValue($this->getRHS(), $params);
$unit = $this->getUnit();
return "DATE_ADD($lhs, INTERVAL $rhs $unit)";
} else if ($sql instanceof PostgreSQL) {
$lhs = $sql->addValue($this->getLHS(), $params);
$rhs = $sql->addValue($this->getRHS(), $params);
$unit = $this->getUnit();
if ($this->getRHS() instanceof Column) {
$rhs = "$rhs * INTERVAL '1 $unit'";
} else {
$rhs = "$rhs $unit";
}
return "$lhs - $rhs";
} else {
throw new Exception("DateAdd Not implemented for driver type: " . get_class($sql));
}
}
}