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