- WIP on SearchRequest attributes - Began working on removing 'Ulmus' class - WIP on removing SQL query building from Repository (which will become SqlRepository)
36 lines
614 B
PHP
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)
|
|
]);
|
|
}
|
|
|
|
}
|