final class Grouping
    implements Node
    uses Snapshot
Public API: explicitly declared with @visibility public.

A GROUP BY clause: the grouping expressions and the super-aggregate modifier.

An item may carry a direction in the 5.x grammars, where GROUP BY also sorted the groups. The selection that holds the clause derives the items. Source: https://dev.mysql.com/doc/refman/8.4/en/group-by-modifiers.html, https://dev.mysql.com/doc/refman/5.7/en/select.html.

Reading the grouping expressionsdoctest
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('SELECT a, b FROM t GROUP BY a, b');
    count($query->statement->groupBy->items) // => 2
Refusing an empty groupingdoctest
new \SqlSemantics\Platform\MySql\Statement\Query\Clause\Grouping([]) // throws \SqlSemantics\Platform\MySql\Model\Diagnostic\InvalidConstruction

Properties§

public non-empty-list<OrderItem> $items
public GroupingModifier|null $modifier = null

Methods§

public function __construct(
    list<OrderItem> $items,
    public GroupingModifier|null $modifier = null,
)

Parameters

$itemslist<OrderItem>The grouping expressions in written order; at least one
$modifierGroupingModifier|nullThe super-aggregate modifier
Calls 2
public function render(Output $out): void

Writes the clause.

Parameters

$outOutput
Calls 5

Test cases 1§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 1

Relations§

Instantiated in 3
Type declarations 3