1 entity.query.inc EntityFieldQuery::finishQuery($select_query, $id_key = 'entity_id')

Finishes the query.

Adds tags, metaData, range and returns the requested list or count.

Parameters

SelectQuery $select_query: A SelectQuery which has entity_type, entity_id, revision_id and bundle fields added.

$id_key: Which field's values to use as the returned array keys.

Return value

See EntityFieldQuery::execute().:

File

core/modules/entity/entity.query.inc, line 935
Entity query API.

Class

EntityFieldQuery
Retrieves entities matching a given set of conditions.

Code

function finishQuery($select_query, $id_key = 'entity_id') {
  foreach ($this->tags as $tag) {
    $select_query->addTag($tag);
  }
  foreach ($this->metaData as $key => $object) {
    $select_query->addMetaData($key, $object);
  }
  $select_query->addMetaData('entity_field_query', $this);
  if ($this->range) {
    $select_query->range($this->range['start'], $this->range['length']);
  }
  if ($this->count) {
    return $select_query->countQuery()->execute()->fetchField();
  }
  $return = array();
  $this->orderedResults = array();
  foreach ($select_query->execute() as $ids) {
    if (!isset($ids->bundle)) {
      $ids->bundle = NULL;
    }
    $return[$ids->entity_type][$ids->$id_key] = $ids;
    $this->ordered_results[] = $ids;
  }
  return $return;
}