class RelationQuery in Relation 7
Handler class for entity relations.
Hierarchy
- class \EntityFieldQuery
- class \RelationQuery
Expanded class hierarchy of RelationQuery
File
- ./
relation.database.inc, line 11 - Database query functions.
View source
class RelationQuery extends EntityFieldQuery {
/**
* Delta group placeholder.
*/
protected $delta_group = 0;
/**
* Constructor for RelationQuery.
*/
function __construct($entity_type = NULL, $entity_id = NULL, $r_index = NULL) {
if (isset($entity_type)) {
$this
->related($entity_type, $entity_id, $r_index);
}
$this
->entityCondition('entity_type', 'relation');
}
/**
* Add a related entity to the query.
*
* @param $entity_type
* Entity type of the related entity.
* @param $entity_id
* Entity id of the related entity. Can be an array of entity IDs.
* @param $r_index
* The index of the related entity within the requested relation(s).
*
* @return RelationQuery
*/
function related($entity_type, $entity_id, $r_index = NULL) {
$this
->fieldCondition('endpoints', 'entity_type', $entity_type, '=', $this->delta_group);
$this
->fieldCondition('endpoints', 'entity_id', $entity_id, NULL, $this->delta_group);
if (isset($r_index)) {
$this
->fieldCondition('endpoints', 'r_index', $r_index, '=', $this->delta_group);
}
$this->delta_group++;
return $this;
}
function execute() {
$results = parent::execute();
if ($this->count) {
return $results;
}
return isset($results['relation']) ? $results['relation'] : array();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityFieldQuery:: |
public | property | Flag indicating whether this is querying current or all revisions. | |
EntityFieldQuery:: |
public | property | TRUE if the query has already been altered, FALSE if it hasn't. | |
EntityFieldQuery:: |
public | property | TRUE if this is a count query, FALSE if it isn't. | |
EntityFieldQuery:: |
public | property | Query behavior for deleted data. | |
EntityFieldQuery:: |
public | property | Associative array of entity-generic metadata conditions. | |
EntityFieldQuery:: |
public | property | The method executing the query, if it is overriding the default. | |
EntityFieldQuery:: |
public | property | List of field conditions. | |
EntityFieldQuery:: |
public | property | List of field meta conditions (language and delta). | |
EntityFieldQuery:: |
public | property | A list of field arrays used. | |
EntityFieldQuery:: |
public | property | A list of metadata added to this query. | |
EntityFieldQuery:: |
public | property | List of order clauses. | |
EntityFieldQuery:: |
public | property | The ordered results. | |
EntityFieldQuery:: |
public | property | The query pager data. | |
EntityFieldQuery:: |
public | property | List of property conditions. | |
EntityFieldQuery:: |
public | property | The query range. | |
EntityFieldQuery:: |
public | property | A list of the tags added to this query. | |
EntityFieldQuery:: |
public | function | Adds a condition to an already built SelectQuery (internal function). | |
EntityFieldQuery:: |
protected | function | Adds the given condition to the proper condition array. | |
EntityFieldQuery:: |
public | function | Adds additional metadata to the query. | |
EntityFieldQuery:: |
public | function | Adds a tag to the query. | |
EntityFieldQuery:: |
public | function | Queries the current or every revision. | |
EntityFieldQuery:: |
public | function | Sets the query to be a count query only. | |
EntityFieldQuery:: |
public | function | Filters on the data being deleted. | |
EntityFieldQuery:: |
public | function | Adds a condition on entity-generic metadata. | |
EntityFieldQuery:: |
public | function | Orders the result set by entity-generic metadata. | |
EntityFieldQuery:: |
public | function | Adds a condition on field values. | |
EntityFieldQuery:: |
public | function | Adds a condition on the field delta column. | |
EntityFieldQuery:: |
public | function | Adds a condition on the field language column. | |
EntityFieldQuery:: |
public | function | Orders the result set by a given field column. | |
EntityFieldQuery:: |
function | Finishes the query. | ||
EntityFieldQuery:: |
function | Gets the total number of results and initializes a pager for the query. | ||
EntityFieldQuery:: |
public | function | Enables a pager for the query. | |
EntityFieldQuery:: |
public | function | Adds a condition on an entity-specific property. | |
EntityFieldQuery:: |
public | function | Orders the result set by an entity-specific property. | |
EntityFieldQuery:: |
protected | function | Queries entity tables in SQL for property conditions and sorts. | |
EntityFieldQuery:: |
public | function | Determines the query callback to use for this entity query. | |
EntityFieldQuery:: |
public | function | Restricts a query to a given range in the result set. | |
EntityFieldQuery:: |
constant | Indicates that both deleted and non-deleted fields should be returned. | ||
EntityFieldQuery:: |
public | function | Enables sortable tables for this query. | |
RelationQuery:: |
protected | property | Delta group placeholder. | |
RelationQuery:: |
function |
Executes the query. Overrides EntityFieldQuery:: |
||
RelationQuery:: |
function | Add a related entity to the query. | ||
RelationQuery:: |
function | Constructor for RelationQuery. |