Framework
3.9
|
AbstractPivotQuery provides the common base class for the shaped pivot query classes PivotQuery, IndexexPivotQuery and GroupedPivotQuery. More...
Public Member Functions | |
__construct ($base, $baseConstraint="") | |
Constructs a new AbstractPivotQuery. More... | |
pivot ($pivotClass, $pivotConstraint, $pivotFunction="SUM") | |
Adds the pivot to the query. More... | |
range ($rangeClass, $rangeConstraint) | |
Adds the range to the query. More... | |
field ($field, $alias="", $type=String) | |
Adds a fixed field to the output object. More... | |
pivotField ($format, $value, $alias=null, $expression="SUM", $type=Number) | |
Adds a pivot field format to the output object. More... | |
createPivotItem () | |
Creates an empty PivotItem, configured with fields and field aliases based on the pivot and range. More... | |
additionalFields () | |
Register additional fields from the base to be included in the PivotItem output. More... | |
Public Member Functions inherited from AbstractQuery | |
constraints ($constraints) | |
Sets the constraint clause for the Query. More... | |
filter ($filter) | |
Sets a filter to constrain the fields retrieved when the query is executed. More... | |
params ($params) | |
Sets the bound parameters array. More... | |
bind () | |
Binds placeholders to parameter values. More... | |
execute () | |
Public Attributes | |
$baseClass | |
$baseConstraint | |
$baseItem | |
$rangeClass | |
$rangeConstraint | |
$pivotClass | |
$pivotConstraint | |
$pivotItem | |
$fields | |
$fieldAliases | |
$additionalFields = array() | |
$groupByFields = array() | |
$orderBy | |
$totalField = null | |
Public Attributes inherited from AbstractQuery | |
$class | |
$constraints | |
$filter | |
$params | |
Protected Member Functions | |
generateFieldExpressions () | |
Builds the expressions for the pivot query. More... | |
generateQuery () | |
Generates SQL for the full pivot query, with grouping. More... | |
AbstractPivotQuery provides the common base class for the shaped pivot query classes PivotQuery, IndexexPivotQuery and GroupedPivotQuery.
Every pivot consists of a 'base', 'range' and 'pivot'. The base is the root object, the pivot is the object that will be pivoted (i.e. have rows converted to columns in the output) and the range is the object that provides the range of values over which this conversion will occur.
AbstractPivotQuery::__construct | ( | $base, | |
$baseConstraint = "" |
|||
) |
Constructs a new AbstractPivotQuery.
string | $base | Class name of the DataItem that will be the base |
string | $baseConstraint | SQL constraint over which the base query will operate. |
Reimplemented from AbstractQuery.
Reimplemented in PivotQuery.
Definition at line 78 of file pivot.inc.
AbstractPivotQuery::additionalFields | ( | ) |
AbstractPivotQuery::createPivotItem | ( | ) |
Creates an empty PivotItem, configured with fields and field aliases based on the pivot and range.
Definition at line 279 of file pivot.inc.
AbstractPivotQuery::field | ( | $field, | |
$alias = "" , |
|||
$type = String |
|||
) |
Adds a fixed field to the output object.
These fields can be from the base object or the pivot object. If they are from the pivot object, then the resulting output will be subgrouped by each fixed field.
string | $field | field in the format "Object.field" |
string | $alias | Alias name for inclusion as labels or column headings in output |
string | $type | Type of the field |
Definition at line 154 of file pivot.inc.
|
protected |
Builds the expressions for the pivot query.
FakoliExpression |
Definition at line 192 of file pivot.inc.
|
protected |
Generates SQL for the full pivot query, with grouping.
Definition at line 236 of file pivot.inc.
AbstractPivotQuery::pivot | ( | $pivotClass, | |
$pivotConstraint, | |||
$pivotFunction = "SUM" |
|||
) |
Adds the pivot to the query.
string | $pivotClass | the class of DataItem that will be the pivot |
string | $pivotConstraint | SQL constraint over which the pivot query will operate |
string | $pivotFunction | default SQL aggregation function used to reduce rows when pivoting (default is SUM, but MAX, MIN, AVG, etc. can also be useful) |
AbstractPivotQuery::pivotField | ( | $format, | |
$value, | |||
$alias = null , |
|||
$expression = "SUM" , |
|||
$type = Number |
|||
) |
Adds a pivot field format to the output object.
One matching output field will be added for each entry in the range.
string | $format | format specifier for the output field (i.e. "pivot_{pivot_id}") |
string | $value | value expression that the field will be populated with. This could be simply a field in the pivot, or it might be a more complex SQL expression |
string | $alias | Alias name for inclusion as labels or column headings in output |
string | $expression | SQL aggregation function used to reduce rows when pivoting (default is SUM, but MAX, MIN, AVG, etc. can also be useful) |
string | $type | Type of the field |
AbstractPivotQuery::range | ( | $rangeClass, | |
$rangeConstraint | |||
) |
Adds the range to the query.
string | $rangeClass | the class of DataItem that will be supplying the range for the pivot |
string | $rangeConstraint | SQL constraint over which the range will operate |
Definition at line 138 of file pivot.inc.