Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
- Minimally maintained
Maintainers monitor issues, but fast responses are not guaranteed. - Maintenance fixes only
Considered feature-complete by its maintainers. - Module categories: Content Editing Experience, Developer Tools, Site Structure
- 3 sites report using this module
- Created by kerasai on , updated
- Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.
Releases
7.x-1.1
released 18 May 2015
Works with Drupal: 7.x
✓ Recommended by the project’s maintainer.
Development version: 7.x-1.x-dev updated 18 May 2015 at 20:23 UTC