public function Numeric::query

Same name in this branch

Set up the query for this argument.

The argument sent may be found at $this->argument.

Overrides ArgumentPluginBase::query

1 method overrides Numeric::query()
UidRevision::query in drupal/core/modules/node/lib/Drupal/node/Plugin/views/argument/UidRevision.php
Set up the query for this argument.

File

drupal/core/modules/views/lib/Drupal/views/Plugin/views/argument/Numeric.php, line 99
Definition of Drupal\views\Plugin\views\argument\Numeric.

Class

Numeric
Basic argument handler for arguments that are numeric. Incorporates break_phrase.

Namespace

Drupal\views\Plugin\views\argument

Code

public function query($group_by = FALSE) {
  $this
    ->ensureMyTable();
  if (!empty($this->options['break_phrase'])) {
    $this
      ->breakPhrase($this->argument, $this);
  }
  else {
    $this->value = array(
      $this->argument,
    );
  }
  $placeholder = $this
    ->placeholder();
  $null_check = empty($this->options['not']) ? '' : "OR {$this->tableAlias}.{$this->realField} IS NULL";
  if (count($this->value) > 1) {
    $operator = empty($this->options['not']) ? 'IN' : 'NOT IN';
    $this->query
      ->add_where_expression(0, "{$this->tableAlias}.{$this->realField} {$operator}({$placeholder}) {$null_check}", array(
      $placeholder => $this->value,
    ));
  }
  else {
    $operator = empty($this->options['not']) ? '=' : '!=';
    $this->query
      ->add_where_expression(0, "{$this->tableAlias}.{$this->realField} {$operator} {$placeholder} {$null_check}", array(
      $placeholder => $this->argument,
    ));
  }
}