Introduction to EFQ

efq image

I gave a presentation to talk about EntityFieldQuery in DrupalACT meetup recently. I decided to talk about EFQ as I found it is so useful and not very popular in Drupal developer world.

EFQ is a class that helps developer to find the entities in Drupal easily. By comparing the EFQ with db_select/db_query layer and the Views module, we can tell in most scenarios when we are dealing with the Drupal entities, EFQ is much better understandable than the db layer. And it is more secure than the Views module. The usage for EFQ is simple and flexible.

However, the EFQ in D7 is not well developed. It can’t provide some requirements such as inner join or random selection. The advanced usage of EFQ (addTag, addMetadata) can give a way to make these features available. The EFQ is still under the development in Drupal 8 where more features have been added in. It will be the main method to get entities in Drupal 8 for sure.  

EFQ.pdf490.24 KB