DataQuery_SubGroup
class DataQuery_SubGroup extends DataQuery implements SQLConditionGroup (View source)
Represents a subgroup inside a WHERE clause in a DataQuery
Stores the clauses for the subgroup inside a specific SQLQuery object.
All non-where methods call their DataQuery versions, which uses the base query object.
Properties
protected | string | $dataClass | from DataQuery | |
protected | SQLQuery | $query | from DataQuery | |
protected | array | $collidingFields | from DataQuery | |
protected | $querySubclasses | from DataQuery | ||
protected | $filterByClassName | from DataQuery | ||
protected | SQLQuery | $whereQuery |
Methods
Return the SQLQuery object that represents the current query; note that it will be a clone of the object.
Remove a filter from the query
Ensure that the query is ready to execute.
Ensure that if a query has an order by clause, those columns are present in the select.
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 ... LIMIT 1 query.
Return the last row that would be returned by this full DataQuery Note that this will issue a separate SELECT ... LIMIT query.
Update the SELECT clause of the query with the columns from the given table
Set the ORDER BY clause of this query
Add an INNER JOIN clause to this query.
Add a LEFT JOIN clause to this query.
Traverse the relationship fields, and add the table mappings to the query object state. This has to be called in any overloaded SearchFilter->apply() methods manually.
Removes the result of query from this query.
Select only the 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.
Determines the resulting SQL along with parameters for the group
Details
__construct(DataQuery $base, $connective)
Create a new DataQuery.
__clone()
Clone this object
string
dataClass()
Return the DataObject class that is being queried.
SQLQuery
query()
Return the SQLQuery object that represents the current query; note that it will be a clone of the object.
$this
removeFilterOn(string|array $fieldExpression)
Remove a filter from the query
initialiseQuery()
Set up the simplest initial query
$this
setQueriedColumns(array $queriedColumns)
No description
SQLQuery
getFinalisedQuery(array|null $queriedColumns = null)
Ensure that the query is ready to execute.
protected null
ensureSelectContainsOrderbyColumns(SQLQuery $query, array $originalSelect = array())
Ensure that if a query has an order by clause, those columns are present in the select.
SS_Query
execute()
Execute the query and return the result as Query object.
string
sql(array $parameters = array())
Return this query's SQL
int
count()
Return the number of records in this query.
Note that this will issue a separate SELECT COUNT() query.
string
max(string $field)
Return the maximum value of the given field in this DataList
string
min(string $field)
Return the minimum value of the given field in this DataList
string
avg(string $field)
Return the average value of the given field in this DataList
string
sum(string $field)
Return the sum of the values of the given field in this DataList
string
aggregate(string $expression)
Runs a raw aggregate expression. Please handle escaping yourself
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.
SQLSelect
lastRow()
Return the last row that would be returned by this full DataQuery Note that this will issue a separate SELECT ... LIMIT query.
protected
selectColumnsFromTable(SQLQuery $query, string $tableClass, array $columns = null)
Update the SELECT clause of the query with the columns from the given table
$this
groupby(string $groupby)
Append a GROUP BY clause to this query.
$this
having(string $having)
Append a HAVING clause to this query.
DataQuery_SubGroup
disjunctiveGroup()
Create a disjunctive subgroup.
That is a subgroup joined by OR
DataQuery_SubGroup
conjunctiveGroup()
Create a conjunctive subgroup
That is a subgroup joined by AND
$this
where(string|array|SQLConditionGroup $filter)
Adds a WHERE clause.
$this
whereAny(string|array|SQLConditionGroup $filter)
Append a WHERE with OR.
$this
sort(string $sort = null, string $direction = null, bool $clear = true)
Set the ORDER BY clause of this query
$this
reverseSort()
Reverse order by clause
limit(int $limit, int $offset = 0)
Set the limit of this query.
$this
distinct(bool $value)
Set whether this query should be distinct or not.
$this
innerJoin(string $table, string $onClause, string $alias = null, int $order = 20, array $parameters = array())
Add an INNER JOIN clause to this query.
$this
leftJoin(string $table, string $onClause, string $alias = null, int $order = 20, array $parameters = array())
Add a LEFT JOIN clause to this query.
string
applyRelation(string|array $relation)
Traverse the relationship fields, and add the table mappings to the query object state. This has to be called in any overloaded SearchFilter->apply() methods manually.
$this
subtract(DataQuery $subtractQuery, string $field = 'ID')
Removes the result of query from this query.
$this
selectFromTable(string $table, array $fields)
Select only the given fields from the given table.
$this
addSelectFromTable(string $table, array $fields)
Add the given fields from the given table to the select statement.
array
column(string $field = 'ID')
Query the given field column from the database and return as an array.
protected string|null
expressionForField(string $field)
No description
protected
selectField(string $fieldExpression, string $alias = null)
Select the given field expressions.
$this
setQueryParam(string $key, mixed $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'.
mixed
getQueryParam(string $key)
Set an arbitrary query parameter, that can be used by decorators to add additional meta-data to the query.
array
getQueryParams()
Returns all query parameters
string
conditionSQL(array $parameters)
Determines the resulting SQL along with parameters for the group