SQL expression rewrite, Pagination, some frontend stuff
This commit is contained in:
24
Core/Driver/SQL/Expression/Count.class.php
Normal file
24
Core/Driver/SQL/Expression/Count.class.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Core\Driver\SQL\Expression;
|
||||
|
||||
use Core\Driver\SQL\SQL;
|
||||
|
||||
class Count extends Alias {
|
||||
public function __construct(mixed $value = "*", string $alias = "count") {
|
||||
parent::__construct($value, $alias);
|
||||
}
|
||||
|
||||
function addValue(SQL $sql, array &$params): string {
|
||||
$value = $this->getValue();
|
||||
if (is_string($value)) {
|
||||
if ($value === "*") {
|
||||
return "COUNT(*)";
|
||||
} else {
|
||||
return "COUNT(" . $sql->columnName($value) . ")";
|
||||
}
|
||||
} else {
|
||||
return "COUNT(" . $sql->addValue($value, $params) . ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user