interface QueryAggregateInterface in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Entity/Query/QueryAggregateInterface.php \Drupal\Core\Entity\Query\QueryAggregateInterface
- 9 core/lib/Drupal/Core/Entity/Query/QueryAggregateInterface.php \Drupal\Core\Entity\Query\QueryAggregateInterface
Defines an interface for aggregated entity queries.
Hierarchy
- interface \Drupal\Core\Database\Query\AlterableInterface
- interface \Drupal\Core\Entity\Query\QueryInterface
- interface \Drupal\Core\Entity\Query\QueryAggregateInterface
- interface \Drupal\Core\Entity\Query\QueryInterface
Expanded class hierarchy of QueryAggregateInterface
All classes that implement QueryAggregateInterface
3 files declare their use of QueryAggregateInterface
- DrupalTest.php in core/
tests/ Drupal/ Tests/ Core/ DrupalTest.php - Query.php in core/
lib/ Drupal/ Core/ Entity/ Query/ Null/ Query.php - QueryAggregate.php in core/
lib/ Drupal/ Core/ Entity/ Query/ Sql/ QueryAggregate.php
File
- core/
lib/ Drupal/ Core/ Entity/ Query/ QueryAggregateInterface.php, line 8
Namespace
Drupal\Core\Entity\QueryView source
interface QueryAggregateInterface extends QueryInterface {
/**
* Specifies a field and a function to aggregate on.
*
* Available functions: SUM, AVG, MIN, MAX and COUNT.
*
* @todo What about GROUP_CONCAT support?
*
* @param string $field
* The name of the field to aggregate by.
* @param string $function
* The aggregation function, for example COUNT or MIN.
* @param string $langcode
* (optional) The language code.
* @param string $alias
* (optional) The key that will be used on the resultset.
*
* @return $this
* The called object.
*/
public function aggregate($field, $function, $langcode = NULL, &$alias = NULL);
/**
* Specifies the field to group on.
*
* @param string $field
* The name of the field to group by.
*
* @return $this
* The called object.
*/
public function groupBy($field);
/**
* Sets a condition for an aggregated value.
*
* @param string $field
* The name of the field to aggregate by.
* @param string $function
* The aggregation function, for example COUNT or MIN.
* @param mixed $value
* The actual value of the field.
* @param $operator
* Possible values:
* - '=', '<>', '>', '>=', '<', '<=', 'STARTS_WITH', 'CONTAINS',
* 'ENDS_WITH': These operators expect $value to be a literal of the
* same type as the column.
* - 'IN', 'NOT IN': These operators expect $value to be an array of
* literals of the same type as the column.
* - 'BETWEEN', 'NOT BETWEEN': These operators expect $value to be an array
* of two literals of the same type as the column.
* @param string $langcode
* (optional) The language code.
*
* @return $this
* The called object.
*
* @see \Drupal\Core\Entity\Query\QueryInterface::condition()
*/
public function conditionAggregate($field, $function = NULL, $value = NULL, $operator = '=', $langcode = NULL);
/**
* Queries for the existence of a field.
*
* @param string $field
* The name of the field.
* @param string $function
* The aggregate function.
* @param $langcode
* (optional) The language code.
*
* @return $this
* The called object.
*/
public function existsAggregate($field, $function, $langcode = NULL);
/**
* Queries for the nonexistence of a field.
*
* @param string $field
* The name of a field.
* @param string $function
* The aggregate function.
* @param string $langcode
* (optional) The language code.
*
* @return $this
* The called object.
*/
public function notExistsAggregate($field, $function, $langcode = NULL);
/**
* Creates an object holding a group of conditions.
*
* See andConditionAggregateGroup() and orConditionAggregateGroup() for more.
*
* @param string $conjunction
* - AND (default): this is the equivalent of andConditionAggregateGroup().
* - OR: this is the equivalent of andConditionAggregateGroup().
*
* @return ConditionInterface
* An object holding a group of conditions.
*/
public function conditionAggregateGroupFactory($conjunction = 'AND');
/**
* Sorts by an aggregated value.
*
* @param string $field
* The name of a field.
* @param string $function
* The aggregate function. This is only marked optional for interface
* compatibility, it is illegal to leave it out.
* @param string $direction
* The order of sorting, either DESC for descending of ASC for ascending.
* @param string $langcode
* (optional) The language code.
*
* @return $this
* The called object.
*/
public function sortAggregate($field, $function, $direction = 'ASC', $langcode = NULL);
/**
* Executes the aggregate query.
*
* @return array
* A list of result row arrays. Each result row contains the aggregate
* results as keys and also the groupBy columns as keys:
*
* @code
* $result = $query
* ->aggregate('nid', 'count')
* ->condition('status', 1)
* ->groupby('type')
* ->execute();
* @endcode
* Will return:
* @code
* $result[0] = array('count_nid' => 3, 'type' => 'page');
* $result[1] = array('count_nid' => 4, 'type' => 'article');
* @endcode
*/
public function execute();
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AlterableInterface:: |
public | function | Adds additional metadata to the query. | 2 |
AlterableInterface:: |
public | function | Adds a tag to a query. | 2 |
AlterableInterface:: |
public | function | Retrieves a given piece of metadata. | 2 |
AlterableInterface:: |
public | function | Determines if a given query has all specified tags. | 2 |
AlterableInterface:: |
public | function | Determines if a given query has any specified tag. | 2 |
AlterableInterface:: |
public | function | Determines if a given query has a given tag. | 2 |
QueryAggregateInterface:: |
public | function | Specifies a field and a function to aggregate on. | |
QueryAggregateInterface:: |
public | function | Sets a condition for an aggregated value. | |
QueryAggregateInterface:: |
public | function | Creates an object holding a group of conditions. | |
QueryAggregateInterface:: |
public | function |
Executes the aggregate query. Overrides QueryInterface:: |
|
QueryAggregateInterface:: |
public | function | Queries for the existence of a field. | |
QueryAggregateInterface:: |
public | function | Specifies the field to group on. | |
QueryAggregateInterface:: |
public | function | Queries for the nonexistence of a field. | |
QueryAggregateInterface:: |
public | function | Sorts by an aggregated value. | |
QueryInterface:: |
public | function | Enables or disables access checking for this query. | 1 |
QueryInterface:: |
public | function | Queries all the revisions. | 1 |
QueryInterface:: |
public | function | Creates a new group of conditions ANDed together. | 1 |
QueryInterface:: |
public | function | Add a condition to the query or a condition group. | 1 |
QueryInterface:: |
public | function | Makes this a count query. | 1 |
QueryInterface:: |
public | function | Limits the query to only default revisions. | 1 |
QueryInterface:: |
public | function | Queries for a non-empty value on a field. | 1 |
QueryInterface:: |
public | function | Gets the ID of the entity type for this query. | 1 |
QueryInterface:: |
public | function | Queries the latest revision. | 1 |
QueryInterface:: |
public | function | Queries for an empty field. | 1 |
QueryInterface:: |
public | function | Creates a new group of conditions ORed together. | 1 |
QueryInterface:: |
public | function | Enables a pager for the query. | 1 |
QueryInterface:: |
public | function | Defines the range of the query. | 1 |
QueryInterface:: |
public | function | Sorts the result set by a given field. | 1 |
QueryInterface:: |
public | function | Enables sortable tables for this query. | 1 |