DataQuery_SubGroup
class DataQuery_SubGroup extends DataQuery implements SQLConditionGroup
Represents a subgroup inside a WHERE clause in a {@link DataQuery}
Stores the clauses for the subgroup inside a specific {@link SQLSelect} object. All non-where methods call their DataQuery versions, which uses the base query object.
Methods
Return the {@link SQLSelect} object that represents the current query; note that it will be a clone of the object.
Ensure that the query is ready to execute.
Return the maximum value of the given field in this DataList
Return the minimum value of the given field in this DataList
Return the average value of the given field in this DataList
Return the sum of the values of the given field in this DataList
Runs a raw aggregate expression. Please handle escaping yourself
Return the first row that would be returned by this full DataQuery Note that this will issue a separate SELECT .
Return the last row that would be returned by this full DataQuery Note that this will issue a separate SELECT .
Set the ORDER BY clause of this query
Add an INNER JOIN clause to this query.
Add a LEFT JOIN clause to this query.
Prefix of all joined table aliases. E.g. ->filter('Banner.Image.Title)'
Will join the Banner, and then Image relations
$relationPrefx
will be banner_image_
Each table in the Image chain will be suffixed to this prefix. E.g.
Traverse the relationship fields, and add the table mappings to the query object state. This has to be called in any overloaded {@link SearchFilter->apply()} methods manually.
Removes the result of query from this query.
Select the only given fields from the given table.
Add the given fields from the given table to the select statement.
Query the given field column from the database and return as an array.
Select the given field expressions.
Set an arbitrary query parameter, that can be used by decorators to add additional meta-data to the query.
Set an arbitrary query parameter, that can be used by decorators to add additional meta-data to the query.
Assign callback to be invoked in getFinalisedQuery()
Determines the resulting SQL along with parameters for the group
Details
at line 24
__construct(DataQuery $base, $connective)
Create a new DataQuery.
in DataQuery at line 82
__clone()
Clone this object
in DataQuery at line 92
string
dataClass()
Return the {@link DataObject} class that is being queried.
in DataQuery at line 103
SQLSelect
query()
Return the {@link SQLSelect} object that represents the current query; note that it will be a clone of the object.
in DataQuery at line 117
$this
removeFilterOn(string|array $fieldExpression)
Remove a filter from the query
in DataQuery at line 189
$this
setQueriedColumns(array $queriedColumns)
in DataQuery at line 201
SQLSelect
getFinalisedQuery(array|null $queriedColumns = null)
Ensure that the query is ready to execute.
in DataQuery at line 425
Query
execute()
Execute the query and return the result as {@link SS_Query} object.
in DataQuery at line 436
string
sql(array $parameters = array())
Return this query's SQL
in DataQuery at line 447
int
count()
Return the number of records in this query.
Note that this will issue a separate SELECT COUNT() query.
in DataQuery at line 460
string
max(string $field)
Return the maximum value of the given field in this DataList
in DataQuery at line 476
string
min(string $field)
Return the minimum value of the given field in this DataList
in DataQuery at line 492
string
avg(string $field)
Return the average value of the given field in this DataList
in DataQuery at line 508
string
sum(string $field)
Return the sum of the values of the given field in this DataList
in DataQuery at line 524
string
aggregate(string $expression)
Runs a raw aggregate expression. Please handle escaping yourself
in DataQuery at line 535
SQLSelect
firstRow()
Return the first row that would be returned by this full DataQuery Note that this will issue a separate SELECT .
.. LIMIT 1 query.
in DataQuery at line 546
SQLSelect
lastRow()
Return the last row that would be returned by this full DataQuery Note that this will issue a separate SELECT .
.. LIMIT query.
in DataQuery at line 596
$this
groupby(string $groupby)
Append a GROUP BY clause to this query.
in DataQuery at line 608
$this
having(mixed $having)
Append a HAVING clause to this query.
in DataQuery at line 621
DataQuery_SubGroup
disjunctiveGroup()
Create a disjunctive subgroup.
That is a subgroup joined by OR
in DataQuery at line 633
DataQuery_SubGroup
conjunctiveGroup()
Create a conjunctive subgroup
That is a subgroup joined by AND
at line 34
$this
where(string|array|SQLConditionGroup $filter)
Adds a WHERE clause.
at line 43
$this
whereAny(string|array|SQLConditionGroup $filter)
Append a WHERE with OR.
in DataQuery at line 684
$this
sort(string $sort = null, string $direction = null, bool $clear = true)
Set the ORDER BY clause of this query
in DataQuery at line 700
$this
reverseSort()
Reverse order by clause
in DataQuery at line 713
$this
limit(int $limit, int $offset)
Set the limit of this query.
in DataQuery at line 725
$this
distinct(bool $value)
Set whether this query should be distinct or not.
in DataQuery at line 743
$this
innerJoin(string $table, string $onClause, string $alias = null, int $order = 20, array $parameters = array())
Add an INNER JOIN clause to this query.
in DataQuery at line 763
$this
leftJoin(string $table, string $onClause, string $alias = null, int $order = 20, array $parameters = array())
Add a LEFT JOIN clause to this query.
in DataQuery at line 784
static string
applyRelationPrefix(string|array $relation)
Prefix of all joined table aliases. E.g. ->filter('Banner.Image.Title)'
Will join the Banner, and then Image relations
$relationPrefx
will be banner_image_
Each table in the Image chain will be suffixed to this prefix. E.g.
banner_image_File
and banner_image_Image
This will be null if no relation is joined.
E.g. ->filter('Title')
in DataQuery at line 808
string
applyRelation(string|array $relation, bool $linearOnly = false)
Traverse the relationship fields, and add the table mappings to the query object state. This has to be called in any overloaded {@link SearchFilter->apply()} methods manually.
Note, that in order to filter against the joined relation user code must use {see tablePrefix()} to get the table alias used for this relation.
in DataQuery at line 1094
$this
subtract(DataQuery $subtractQuery, string $field = 'ID')
Removes the result of query from this query.
in DataQuery at line 1114
$this
selectFromTable(string $table, array $fields)
Select the only given fields from the given table.
in DataQuery at line 1132
$this
addSelectFromTable(string $table, array $fields)
Add the given fields from the given table to the select statement.
in DataQuery at line 1149
array
column(string $field = 'ID')
Query the given field column from the database and return as an array.
in DataQuery at line 1190
selectField(string $fieldExpression, string $alias = null)
Select the given field expressions.
in DataQuery at line 1210
$this
setQueryParam(string $key, string|array $value)
Set an arbitrary query parameter, that can be used by decorators to add additional meta-data to the query.
It's expected that the $key will be namespaced, e.g, 'Versioned.stage' instead of just 'stage'.
in DataQuery at line 1222
string
getQueryParam(string $key)
Set an arbitrary query parameter, that can be used by decorators to add additional meta-data to the query.
in DataQuery at line 1234
array
getQueryParams()
Returns all query parameters
in DataQuery at line 1244
DataQueryManipulator[]
getDataQueryManipulators()
Get query manipulators
in DataQuery at line 1255
$this
pushQueryManipulator(DataQueryManipulator $manipulator)
Assign callback to be invoked in getFinalisedQuery()
at line 52
string
conditionSQL(array $parameters)
Determines the resulting SQL along with parameters for the group