ulmus/src/Query/GroupBy.php
Dave Mc Nicoll 9fdebf454d - Started working on decoupling QueryBuilder from SqlQueryBuilder
- WIP on SearchRequest attributes
- Began working on removing 'Ulmus' class
- WIP on removing SQL query building from Repository (which will become SqlRepository)
2024-04-17 15:54:48 -04:00

36 lines
614 B
PHP

<?php
namespace Ulmus\Query;
class GroupBy extends Fragment {
public int $order = 75;
public array $groupBy = [];
const SQL_TOKEN = "GROUP BY";
public function set(array $fields) : self
{
$this->groupBy = $fields;
return $this;
}
public function add(string $field) : self
{
$this->validateFieldType($field);
$this->groupBy[] = $field;
return $this;
}
public function render() : string
{
return $this->renderSegments([
static::SQL_TOKEN, implode(", ", $this->groupBy)
]);
}
}