You are here

public function views_handler_argument_numeric::query in Views (for Drupal 7) 7.3

Same name and namespace in other branches
  1. 6.3 handlers/views_handler_argument_numeric.inc \views_handler_argument_numeric::query()
  2. 6.2 handlers/views_handler_argument_numeric.inc \views_handler_argument_numeric::query()

Set up the query for this argument.

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

Parameters

bool $group_by: Whether the query uses a group-by.

Overrides views_handler_argument::query

File

handlers/views_handler_argument_numeric.inc, line 105
Definition of views_handler_argument_numeric.

Class

views_handler_argument_numeric
Basic argument handler for arguments that are numeric.

Code

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