QBResult
Overview
The QBResult
class serves as a wrapper for managing query results in the QBSelect
framework. It enables precise control over the structure and content of query results, including the addition of columns, aggregates, functions, case expressions, and subqueries. This flexibility allows developers to define custom outputs that align with specific SQL requirements.
Key features include support for distinct results, dynamic addition or removal of result components, and methods to include primary key columns automatically. Notable methods include add(column, alias)
to add columns with aliases, addSubSelect(query, alias)
for embedding subqueries, and remove(name)
to remove a column by its name.
For further details, refer to the QBSelect documentation.
Properties Summarized
Methods Summarized
Properties Detailed
distinct
Get/set the distinct flag for the query.
Type Boolean The current state of the distinct flag for the query.
Sample
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(aggregate)
Add an aggregate to the query result.
Parameters
QBColumn aggregate the aggregate to add to result
Returns: QBResult The query result object with the specified aggregate and alias added.
Sample
add(aggregate, alias)
Add an aggregate with alias to the query result.
Parameters
Returns: QBResult The query result object with the specified function added.
Sample
add(column)
Add a column to the query result.
Parameters
QBColumn column column to add to result
Returns: QBResult The query result object with the specified column added.
Sample
add(column, alias)
Add a column with alias to the query result.
Parameters
Returns: QBResult The query result object with the specified column and alias added.
Sample
add(columns)
Add all columns from a query or a join to the query result.
Parameters
QBColumns columns columns to add to result
Returns: QBResult The query result object with all columns from the specified query or join added.
Sample
add(func)
Add a function result to the query result.
Parameters
QBColumn func the function to add to the result
Returns: QBResult The query result object with the specified function and alias added.
Sample
add(func, alias)
Add a function with alias result to the query result.
Parameters
Returns: QBResult The query result object with the specified searched case expression added.
Sample
add(qcase)
Add a case searched expression to the query result.
Parameters
QBColumn qcase The searched case expression.
Returns: QBResult The query result object with the specified searched case expression added.
Sample
add(qcase, alias)
Add a case searched expression with alias to the query result.
Parameters
Returns: QBResult The query result object with the specified searched case expression and alias added.
Sample
addPk()
Add the tables' primary pk columns in alphabetical order to the query result.
Returns: QBResult The query result object with primary key columns added.
Sample
addSubSelect(query)
Add a query to the query result.
Parameters
QBSelect query query to add to result
Returns: QBResult The query result object with the specified query added.
Sample