Check your version

This video covers a topic in Drupal 7 which may or may not be the version you're using. We're keeping this tutorial online as a courtesy to users of Drupal 7, but we consider it archived.

Alternate resources: 

Make Lists of Entities with Entity Field Query

Video loading...

Join Drupalize.Me to watch this video

Join today and gain instant access to our entire video library.

Log in Sign up
  • 0:05
    [Joe Shindelar] Having a system like the Entity API in Drupal makes it so that we can write code that's really generic
  • 0:11
    and will work in all kinds of different situations with all different types of entities.
  • 0:16
    This does provide some problems, though.
  • 0:18
    It can be hard to query for and get a list of all the entities
  • 0:22
    when you don't even know what all of the entity types are.
  • 0:26
    That's why we use a class in Drupal 7 called Entity Field Query
  • 0:31
    in order to build queries to list entities.
  • 0:34
    Rather than querying the database directly, we'll use the Entity Field Query class
  • 0:40
    to build up lists of conditions to query against entities' properties and fields.
  • 0:45
    We do this because in Drupal, we don't necessarily always know

Make Lists of Entities with Entity Field Query

Loading...

This lesson will explore the use of EntityFieldQuery to retrieve lists of entities from Drupal without directly querying the database which can be problematic in a system where the underlying schema can change depending on configuration settings in the user interface. Again focusing on writing code that will work with any entity in Drupal and isn't hard coded to your particular setup.

Downloads: 
Log in or sign up to download companion files.
Additional resources: