You are here

function views_handler_argument_many_to_one::query in Views (for Drupal 7) 6.3

Same name and namespace in other branches
  1. 6.2 handlers/views_handler_argument_many_to_one.inc \views_handler_argument_many_to_one::query()
  2. 7.3 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.

Overrides views_handler_argument::query

File

handlers/views_handler_argument_many_to_one.inc, line 76

Class

views_handler_argument_many_to_one
An argument handler for use in fields that have a many to one relationship with the table(s) to the left. This adds a bunch of options that are reasonably common with this type of relationship. Definition terms:

Code

function query() {
  $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} 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();
}