GroupBy trait

Framework\Database\Manipulation\Traits\GroupBy

Trait GroupBy.

Defined in libraries/database/src/Manipulation/Traits/GroupBy.php

Methods #

groupBy()
Appends columns to the GROUP BY clause.
groupByAsc()
Appends columns with the ASC direction to the GROUP BY clause.
groupByDesc()
Appends columns with the DESC direction to the GROUP BY clause.
renderGroupBy()
Renders the GROUP BY clause.
addGroupBy()
Adds a GROUP BY expression.

groupBy()

public function groupBy(Closure|string $column, Closure|string ...$columns): static

Appends columns to the GROUP BY clause.

Parameters
  • Closure|string $column - The column name or a subquery
  • Closure|string $columns
Returns static

groupByAsc()

public function groupByAsc(Closure|string $column, Closure|string ...$columns): static

Appends columns with the ASC direction to the GROUP BY clause.

Parameters
  • Closure|string $column - The column name or a subquery
  • Closure|string $columns
Returns static

groupByDesc()

public function groupByDesc(Closure|string $column, Closure|string ...$columns): static

Appends columns with the DESC direction to the GROUP BY clause.

Parameters
  • Closure|string $column - The column name or a subquery
  • Closure|string $columns
Returns static

renderGroupBy()

protected function renderGroupBy(): ?string

Renders the GROUP BY clause.

Returns ?string - The GROUP BY clause or null if it was not set

addGroupBy()

private function addGroupBy(Closure|string $column, array $columns, ?string $direction): static

Adds a GROUP BY expression.

Parameters
  • Closure|string $column - The column name or a subquery
  • array $columns - Extra column names and/or subqueries
  • ?string $direction - `ASC`, `DESC` or null for none
Returns static