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,17 +2,29 @@
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 Exception;
class JsonArrayAgg extends Expression {
private $value;
private string $alias;
private mixed $value;
public function __construct($value, string $alias) {
public function __construct(mixed $value) {
$this->value = $value;
$this->alias = $alias;
}
public function getValue() { return $this->value; }
public function getAlias(): string { return $this->alias; }
public function getExpression(SQL $sql, array &$params): string {
$value = is_string($this->value) ? new Column($this->value) : $this->value;
$value = $sql->addValue($value, $params);
if ($sql instanceof MySQL) {
return "JSON_ARRAYAGG($value)";
} else if ($sql instanceof PostgreSQL) {
return "JSON_AGG($value)";
} else {
throw new Exception("JsonArrayAgg not implemented for driver type: " . get_class($sql));
}
}
}