You are here

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

Same name and namespace in other branches
  1. 6.3 handlers/views_handler_argument_many_to_one.inc \views_handler_argument_many_to_one::query()
  2. 6.2 handlers/views_handler_argument_many_to_one.inc \views_handler_argument_many_to_one::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_many_to_one.inc, line 108
Definition of views_handler_argument_many_to_one.

Class

views_handler_argument_many_to_one
Argument handler for fields that have many-to-one table relationships.

Code

public function query($group_by = FALSE) {
  $empty = FALSE;
  if (isset($this->definition['zero is null']) && $this->definition['zero is null']) {
    if (empty($this->argument)) {
      $empty = TRUE;
    }
  }
  else {
    if (!isset($this->argument)) {
      $empty = TRUE;
    }
  }
  if ($empty) {
    parent::ensure_my_table();
    $this->query
      ->add_where(0, "{$this->table_alias}.{$this->real_field}", NULL, 'IS NULL');
    return;
  }
  if (!empty($this->options['break_phrase'])) {
    views_break_phrase($this->argument, $this);
  }
  else {
    $this->value = array(
      $this->argument,
    );
    $this->operator = 'or';
  }
  $this->helper
    ->add_filter();
}