pagination + sql expressions + frontend improvements
This commit is contained in:
28
Core/Driver/SQL/Expression/AbstractFunction.class.php
Normal file
28
Core/Driver/SQL/Expression/AbstractFunction.class.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Core\Driver\SQL\Expression;
|
||||
|
||||
use Core\Driver\SQL\SQL;
|
||||
|
||||
abstract class AbstractFunction extends Expression {
|
||||
|
||||
private string $functionName;
|
||||
private mixed $value;
|
||||
|
||||
public function __construct(string $functionName, mixed $value) {
|
||||
$this->functionName = $functionName;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public function getExpression(SQL $sql, array &$params): string {
|
||||
return $this->functionName . "(" . $sql->addValue($this->getValue(), $params) . ")";
|
||||
}
|
||||
|
||||
public function getFunctionName(): string {
|
||||
return $this->functionName;
|
||||
}
|
||||
|
||||
public function getValue(): mixed {
|
||||
return $this->value;
|
||||
}
|
||||
}
|
||||
@@ -2,21 +2,10 @@
|
||||
|
||||
namespace Core\Driver\SQL\Expression;
|
||||
|
||||
use Core\Driver\SQL\SQL;
|
||||
|
||||
class Distinct extends Expression {
|
||||
|
||||
private mixed $value;
|
||||
class Distinct extends AbstractFunction {
|
||||
|
||||
public function __construct(mixed $value) {
|
||||
$this->value = $value;
|
||||
parent::__construct("DISTINCT", $value);
|
||||
}
|
||||
|
||||
public function getValue(): mixed {
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
function getExpression(SQL $sql, array &$params): string {
|
||||
return "DISTINCT(" . $sql->addValue($this->getValue(), $params) . ")";
|
||||
}
|
||||
}
|
||||
11
Core/Driver/SQL/Expression/Lower.class.php
Normal file
11
Core/Driver/SQL/Expression/Lower.class.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Core\Driver\SQL\Expression;
|
||||
|
||||
class Lower extends AbstractFunction {
|
||||
|
||||
public function __construct(mixed $value) {
|
||||
parent::__construct("LOWER", $value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,15 +2,10 @@
|
||||
|
||||
namespace Core\Driver\SQL\Expression;
|
||||
|
||||
use Core\Driver\SQL\SQL;
|
||||
class Sum extends AbstractFunction {
|
||||
|
||||
class Sum extends Alias {
|
||||
|
||||
public function __construct(mixed $value, string $alias) {
|
||||
parent::__construct($value, $alias);
|
||||
public function __construct(mixed $value) {
|
||||
parent::__construct("SUM", $value);
|
||||
}
|
||||
|
||||
protected function addValue(SQL $sql, array &$params): string {
|
||||
return "SUM(" . $sql->addValue($this->getValue(), $params) . ")";
|
||||
}
|
||||
}
|
||||
11
Core/Driver/SQL/Expression/Upper.class.php
Normal file
11
Core/Driver/SQL/Expression/Upper.class.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Core\Driver\SQL\Expression;
|
||||
|
||||
class Upper extends AbstractFunction {
|
||||
|
||||
public function __construct(mixed $value) {
|
||||
parent::__construct("UPPER", $value);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user