QBGroupBy
Overview
The QBGroupBy
class is utilized to define SQL GROUP BY
conditions within a QBSelect
query. It allows adding columns, functions, or primary key columns to the GROUP BY
clause. This class also provides the capability to clear the existing GROUP BY
clause, ensuring flexibility in query construction.
Key Features
The parent
property links the QBGroupBy
instance to its parent table clause, which can be a query or a join clause. The root
property provides access to the parent query builder, enabling hierarchical query manipulation.
The add(column)
and add(function)
methods enable adding columns or functions to the GROUP BY
clause, supporting aggregation queries. The addPk()
method simplifies grouping by adding primary key columns in alphabetical order. Additionally, the clear()
method removes all conditions from the GROUP BY
clause, allowing for dynamic query adjustments.
For further details on query construction and execution, refer to the QBSelect section of the documentation.
Properties Summarized
Methods Summarized
Properties Detailed
parent
Get query builder parent table clause, this may be a query or a join clause.
Type QBSelect
Sample
root
Get query builder parent.
Type QBSelect
Sample
Methods Detailed
add(column)
Add column name to group-by clause.
Same as query.groupBy().add(join.getColumn("value"))
Parameters
QBColumn column the column to add to the query condition
Returns: QBGroupBy
Sample
add(function)
Add column name to group-by clause.
Same as query.groupBy().add(join.getColumn("value"))
Parameters
QBColumn function the function to add to the query
Returns: QBGroupBy
Sample
addPk()
Add the tables' primary pk columns in alphabetical order to the group by clause.
Returns: QBGroupBy
Sample
clear()
Clear the to group-by clause.
Returns: QBGroupBy
Sample
Last updated