7.x entity.inc public EntityFieldQuery::entityCondition($name, $value, $operator = NULL)

Adds a condition on entity-generic metadata.

If the overall query contains only entity conditions or ordering, or if there are property conditions, then specifying the entity type is mandatory. If there are field conditions or ordering but no property conditions or ordering, then specifying an entity type is optional. While the field storage engine might support field conditions on more than one entity type, there is no way to query across multiple entity base tables by default. To specify the entity type, pass in 'entity_type' for $name, the type as a string for $value, and no $operator (it's disregarded).

'bundle', 'revision_id' and 'entity_id' have no such restrictions.

Note: The "comment" entity type does not support bundle conditions.


$name: 'entity_type', 'bundle', 'revision_id' or 'entity_id'.

$value: The value for $name. In most cases, this is a scalar. For more complex options, it is an array. The meaning of each element in the array is dependent on $operator.

$operator: Possible values:

  • '=', '<>', '>', '>=', '<', '<=', 'STARTS_WITH', 'CONTAINS': These operators expect $value to be a literal of the same type as the column.
  • 'IN', 'NOT IN': These operators expect $value to be an array of literals of the same type as the column.
  • 'BETWEEN': This operator expects $value to be an array of two literals of the same type as the column.

The operator can be omitted, and will default to 'IN' if the value is an array, or to '=' otherwise.

Return value

EntityFieldQuery The called object.


includes/entity.inc, line 669


Retrieves entities matching a given set of conditions.


public function entityCondition($name, $value, $operator = NULL) {
  // The '!=' operator is deprecated in favour of the '<>' operator since the
  // latter is ANSI SQL compatible.
  if ($operator == '!=') {
    $operator = '<>';
  $this->entityConditions[$name] = array(
    'value' => $value,
    'operator' => $operator,
  return $this;


p4ul’s picture

now that $conditions is deprecated in
file_load_multiple($fids = array(), $conditions = array())

you can use the following:

$query = new EntityFieldQuery();
$result = $query->entityCondition('entity_type', 'file')
->propertyCondition('uri', $fileURI)

to load the actual file you can use something like this

if($result) {
 $row = array_pop(array_pop($result));