4

Best practice deems that you should use EntityFieldQuery for queries that somehow involve fields and entities.

An example of query to look for nodes with a timestamp value set in the future would be the following code.

$query = new EntityFieldQuery();
$result = $query->entityCondition('entity_type', 'node')
  ->fieldCondition('field_foo', 'value', REQUEST_TIME, '>')
  ->execute();

Is applying the conditions on all revisions, instead of only the active revision, possible?

A direct query on the database tables used to store the field revision values could eventually stop to work when Drupal changes some implementation details, such as the name of the used database tables, or the data stored in those database tables.

1

Yes. EntityFieldQuery has a method, EntityFieldQuery::age(), which is used to limit the revisions of the returned entities. It can be set to:

Support for this value ultimately depends on the query callback. The default query callback, field_sql_storage_field_storage_query(), which is the hook_field_storage_query() implementation done from the field storage module, uses it to query the appropriate revision tables.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.