function QueryConditionInterface::condition

Helper function: builds the most common conditional clauses.

This method can take a variable number of parameters. If called with two parameters, they are taken as $field and $value with $operator having a value of IN if $value is an array and = otherwise.

Do not use this method to test for NULL values. Instead, use QueryConditionInterface::isNull() or QueryConditionInterface::isNotNull().

Parameters

$field: The name of the field to check. If you would like to add a more complex condition involving operators or functions, use where().

$value: The value to test the field against. 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 the $operator.

$operator: The comparison operator, such as =, <, or >=. It also accepts more complex options such as IN, LIKE, or BETWEEN. Defaults to IN if $value is an array, and = otherwise.

Return value

QueryConditionInterface The called object.

See also

QueryConditionInterface::isNull()

QueryConditionInterface::isNotNull()

6 methods override QueryConditionInterface::condition()
DatabaseCondition::condition in includes/database/query.inc
Implements QueryConditionInterface::condition().
DeleteQuery::condition in includes/database/query.inc
Implements QueryConditionInterface::condition().
MergeQuery::condition in includes/database/query.inc
Implements QueryConditionInterface::condition().
SelectQuery::condition in includes/database/select.inc
Helper function: builds the most common conditional clauses.
SelectQueryExtender::condition in includes/database/select.inc
Helper function: builds the most common conditional clauses.

... See full list

File

includes/database/query.inc, line 46

Class

QueryConditionInterface
Interface for a conditional clause in a query.

Code

public function condition($field, $value = NULL, $operator = NULL);

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.