public function ConditionInterface::condition

Same name in this branch
  1. 9.x drupal/core/lib/Drupal/Core/Entity/Query/ConditionInterface.php \Drupal\Core\Entity\Query\ConditionInterface::condition()
  2. 9.x drupal/core/lib/Drupal/Core/Database/Query/ConditionInterface.php \Drupal\Core\Database\Query\ConditionInterface::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

Drupal\Core\Database\Query\ConditionInterface::isNull()

Drupal\Core\Database\Query\ConditionInterface::isNotNull()

6 methods override ConditionInterface::condition()
Condition::condition in drupal/core/lib/Drupal/Core/Database/Query/Condition.php
Implements Drupal\Core\Database\Query\ConditionInterface::condition().
Delete::condition in drupal/core/lib/Drupal/Core/Database/Query/Delete.php
Implements Drupal\Core\Database\Query\ConditionInterface::condition().
Merge::condition in drupal/core/lib/Drupal/Core/Database/Query/Merge.php
Implements Drupal\Core\Database\Query\ConditionInterface::condition().
Select::condition in drupal/core/lib/Drupal/Core/Database/Query/Select.php
Helper function: builds the most common conditional clauses.
SelectExtender::condition in drupal/core/lib/Drupal/Core/Database/Query/SelectExtender.php
Helper function: builds the most common conditional clauses.

... See full list

File

drupal/core/lib/Drupal/Core/Database/Query/ConditionInterface.php, line 45
Definition of Drupal\Core\Database\Query\ConditionInterface

Class

ConditionInterface
Interface for a conditional clause in a query.

Namespace

Drupal\Core\Database\Query

Code

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