function views_handler_argument_numeric::query

Same name in other branches
  1. 7.x-3.x handlers/views_handler_argument_numeric.inc \views_handler_argument_numeric::query()

Overrides views_handler_argument::query

File

handlers/views_handler_argument_numeric.inc, line 73

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);
    }
}