function Condition::condition

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Database/Query/Condition.php \Drupal\Core\Database\Query\Condition::condition()
  2. 10 core/lib/Drupal/Core/Database/Query/Condition.php \Drupal\Core\Database\Query\Condition::condition()
  3. 11.x core/lib/Drupal/Core/Database/Query/Condition.php \Drupal\Core\Database\Query\Condition::condition()

Overrides ConditionInterface::condition

4 calls to Condition::condition()
Condition::exists in core/lib/Drupal/Core/Database/Query/Condition.php
Sets a condition that the specified subquery returns values.
Condition::isNotNull in core/lib/Drupal/Core/Database/Query/Condition.php
Sets a condition that the specified field be NOT NULL.
Condition::isNull in core/lib/Drupal/Core/Database/Query/Condition.php
Sets a condition that the specified field be NULL.
Condition::notExists in core/lib/Drupal/Core/Database/Query/Condition.php
Sets a condition that the specified subquery returns no values.

File

core/lib/Drupal/Core/Database/Query/Condition.php, line 112

Class

Condition
Generic class for a series of conditions in a query.

Namespace

Drupal\Core\Database\Query

Code

public function condition($field, $value = NULL, $operator = '=') {
    if (empty($operator)) {
        $operator = '=';
    }
    if (empty($value) && is_array($value)) {
        throw new InvalidQueryException(sprintf("Query condition '%s %s ()' cannot be empty.", $field, $operator));
    }
    $this->conditions[] = [
        'field' => $field,
        'value' => $value,
        'operator' => $operator,
    ];
    $this->changed = TRUE;
    return $this;
}

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