- Fixed GroupBy
This commit is contained in:
parent
538af38769
commit
5d00a7e394
|
@ -4,11 +4,8 @@ namespace Ulmus\Entity\Field;
|
|||
|
||||
class Date extends Datetime {
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->format("Y-m-d");
|
||||
}
|
||||
|
||||
public string $format = "Y-m-d";
|
||||
|
||||
public function formatLocale(string $format) : string
|
||||
{
|
||||
return strftime($format, $this->getTimestamp());
|
||||
|
|
|
@ -4,9 +4,6 @@ namespace Ulmus\Entity\Field;
|
|||
|
||||
class Time extends Datetime {
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->format("H:i:s");
|
||||
}
|
||||
public string $format = "H:i:s";
|
||||
|
||||
}
|
||||
|
|
|
@ -3,22 +3,23 @@
|
|||
namespace Ulmus\Query;
|
||||
|
||||
class GroupBy extends Fragment {
|
||||
|
||||
const SQL_TOKEN = "GROUP BY";
|
||||
|
||||
public int $order = 70;
|
||||
public int $order = 75;
|
||||
|
||||
public array $groupBy = [];
|
||||
|
||||
const SQL_TOKEN = "GROUP BY";
|
||||
|
||||
public function set(array $order) : self
|
||||
{
|
||||
$this->groupBy = $order;
|
||||
$this->groupBy = [ $order ];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function add(string $field, ? string $direction = null) : self
|
||||
public function add(string $field) : self
|
||||
{
|
||||
$this->groupBy[] = $field;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,5 +4,6 @@ namespace Ulmus\Query;
|
|||
|
||||
class Having extends Where {
|
||||
const SQL_TOKEN = "HAVING";
|
||||
public int $order = 75;
|
||||
|
||||
public int $order = 80;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
namespace Ulmus\Query;
|
||||
|
||||
class OrderBy extends Fragment {
|
||||
public int $order = 80;
|
||||
public int $order = 85;
|
||||
|
||||
public array $orderBy = [];
|
||||
|
||||
|
|
|
@ -216,11 +216,6 @@ class QueryBuilder
|
|||
return $this->where($field, $value, $operator, true);
|
||||
}
|
||||
|
||||
public function groupBy() : self
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function limit(int $value) : self
|
||||
{
|
||||
if ( null === $limit = $this->getFragment(Query\Limit::class) ) {
|
||||
|
@ -257,6 +252,18 @@ class QueryBuilder
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function groupBy(string $field, ? string $direction = null) : self
|
||||
{
|
||||
if ( null === $groupBy = $this->getFragment(Query\GroupBy::class) ) {
|
||||
$groupBy = new Query\GroupBy();
|
||||
$this->push($groupBy);
|
||||
}
|
||||
|
||||
$groupBy->add($field, $direction);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function join(string $type, /*string | QueryBuilder*/ $table, $field, $value, bool $outer = false, ? string $alias = null) : self
|
||||
{
|
||||
$join = new Query\Join($this);
|
||||
|
|
Loading…
Reference in New Issue