Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Sql.php

function Sql::addWhereExpression

Adds a complex WHERE clause to the query.

The caller is responsible for ensuring that all fields are fully qualified (TABLE.FIELD) and that the table already exists in the query. Internally the dbtng method "where" is used.

Parameters

$group: The WHERE group to add these to; groups are used to create AND/OR sections. Groups cannot be nested. Use 0 as the default group. If the group does not yet exist it will be created as an AND group.

$snippet: The snippet to check. This can be either a column or a complex expression like "UPPER(table.field) = 'value'"

$args: An associative array of arguments.

See also

QueryConditionInterface::where()

File

core/modules/views/src/Plugin/views/query/Sql.php, line 995

Class

Sql
Views query plugin for an SQL query.

Namespace

Drupal\views\Plugin\views\query

Code

public function addWhereExpression($group, $snippet, $args = []) {
    // Ensure all variants of 0 are actually 0. Thus '', 0 and NULL are all
    // the default group.
    if (empty($group)) {
        $group = 0;
    }
    // Check for a group.
    if (!isset($this->where[$group])) {
        $this->setWhereGroup('AND', $group);
    }
    $this->where[$group]['conditions'][] = [
        'field' => $snippet,
        'value' => $args,
        'operator' => 'formula',
    ];
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal