function views_handler_argument_numeric::query

3.x views_handler_argument_numeric.inc views_handler_argument_numeric::query($group_by = FALSE)
2.x 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.

Overrides views_handler_argument::query

File

handlers/views_handler_argument_numeric.inc, line 73
Contains the numeric argument handler.

Class

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

Code

function query() {
  $this->ensure_my_table();

  if (!empty($this->options['break_phrase'])) {
    views_break_phrase($this->argument, $this);
  }
  else {
    $this->value = array($this->argument);
  }

  $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';
    $placeholders = implode(', ', array_fill(0, sizeof($this->value), '%d'));
    $this->query->add_where(0, "$this->table_alias.$this->real_field $operator ($placeholders) $null_check", $this->value);
  }
  else {
    $operator = empty($this->options['not']) ? '=' : '!=';
    $this->query->add_where(0, "$this->table_alias.$this->real_field $operator %d $null_check", $this->argument);
  }
}