4

Background

Best practice deems that you should use EntityFieldQuery (d7) for making queries that somehow involves fields on entites.

An example of such a query could look like this.

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

In the above example, we are looking for nodes which has a timestamp value set in the future, it works just fine and all is good.

Question

Is it possible using these APIs (which handles that fields potentially could be stored anywhere), and apply the condition on all revisions, instead of only the active revision?

When using SQL, you could make a custom query on the field_revision_FIELDNAME table, but doing this would require you to make some database assumptions and break best practice.

0

Yes. EntityFieldQuery has a property EntityFieldQuery::$age that is a flag for the age of the returned entity revision. It can be set to:

Support for this flag ultimately depends on the EFQ's queryCallback function. In the default field_sql_storage_field_storage_query() function, it is recognized and queries the appropriate revision tables accordingly.

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.