- Fixed Entity::field("propertyname") function to look for name into @Field() annotation and returns it if it exists. - A lot of bug fixes made into SQL fragments.
33 lines
592 B
PHP
33 lines
592 B
PHP
<?php
|
|
|
|
namespace Ulmus\Query;
|
|
|
|
class GroupBy extends Fragment {
|
|
|
|
const SQL_TOKEN = "GROUP BY";
|
|
|
|
public int $order = 70;
|
|
|
|
public array $groupBy = [];
|
|
|
|
public function set(array $order) : self
|
|
{
|
|
$this->groupBy = $order;
|
|
return $this;
|
|
}
|
|
|
|
public function add(string $field, ? string $direction = null) : self
|
|
{
|
|
$this->groupBy[] = $field;
|
|
return $this;
|
|
}
|
|
|
|
public function render() : string
|
|
{
|
|
return $this->renderSegments([
|
|
static::SQL_TOKEN, implode(", ", $this->groupBy)
|
|
]);
|
|
}
|
|
|
|
}
|