| 7 entity.inc | public EntityFieldQuery::entityCondition($name, $value, $operator = NULL) |
| 8 entity.query.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" and "taxonomy_term" entity types don't support bundle conditions. For "taxonomy_term", propertyCondition('vid') can be used instead.
Parameters
$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.
File
- includes/
entity.inc, line 622
Code
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;
}
Login or register to post comments
Comments
Is there any `OR`?
Can we use `OR` with entityCondition (or any other conditions: fieldCondition and propertyCondition)?