Entity field queries are a powerful tool for quering data from Drupal's entity system. This module provides a EfqHelper class which extends the EntityFieldQuery class providing shortcuts to common EFQ usage. This is a module intended to assist in development and provides no functionality visible to an end user.

Example Usage

Here is an example to load the last 10 article type (bundle) nodes created with field_featured (a checkbox, perhaps) set to 1.

// Specify which entity type you're querying.
$query = new EfqHelper('node');

// Use standard EFQ methods to set the query.
$query->propertyCondition('status', 1)
  ->propertyCondition('type', 'article')
  ->fieldCondition('field_featured', 'value', 1)
  ->propertyOrderBy('created', 'DESC')
  ->range(0, 10);

// You can still get the raw EFQ data by calling the execute() method, this gives you "stub" entities.
$result = $query->execute();

// To get the fully-loaded nodes, simply call the result() method. Calling the execute() method before calling the result() method is optional.
$nodes = $query->result();
// To get the the fully-loaded node of the first result, call the first() method.
$node = $query->first();
// To get the the entity IDs from the result set, call the ids() method.
$nids = $query->ids();

Project information

Releases