You are here

protected function Query::result in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Entity/Query/Sql/Query.php \Drupal\Core\Entity\Query\Sql\Query::result()
  2. 9 core/lib/Drupal/Core/Entity/Query/Sql/Query.php \Drupal\Core\Entity\Query\Sql\Query::result()

Executes the query and returns the result.

Return value

int|array Returns the query result as entity IDs.

File

core/lib/Drupal/Core/Entity/Query/Sql/Query.php, line 263

Class

Query
The SQL storage entity query class.

Namespace

Drupal\Core\Entity\Query\Sql

Code

protected function result() {
  if ($this->count) {
    return $this->sqlQuery
      ->countQuery()
      ->execute()
      ->fetchField();
  }

  // Return a keyed array of results. The key is either the revision_id or
  // the entity_id depending on whether the entity type supports revisions.
  // The value is always the entity id.
  return $this->sqlQuery
    ->execute()
    ->fetchAllKeyed();
}