1 handlers.inc views_many_to_one_helper::summary_join()

Provide the proper join for summary queries. This is important in part because it will cooperate with other arguments if possible.

File

core/modules/views/includes/handlers.inc, line 745
Defines the various handler objects to help build and display views.

Class

views_many_to_one_helper

Code

function summary_join() {
  $field = $this->handler->relationship . '_' . $this->handler->table . '.' . $this->handler->field;
  $join = $this->get_join();

  // shortcuts
  $options = $this->handler->options;
  $view = &$this->handler->view;
  $query = &$this->handler->query;

  if (!empty($options['require_value'])) {
    $join->type = 'INNER';
  }

  if (empty($options['add_table']) || empty($view->many_to_one_tables[$field])) {
    return $query->ensure_table($this->handler->table, $this->handler->relationship, $join);
  }
  else {
    if (!empty($view->many_to_one_tables[$field])) {
      foreach ($view->many_to_one_tables[$field] as $value) {
        $join->extra = array(
          array(
            'field' => $this->handler->real_field,
            'operator' => '!=',
            'value' => $value,
            'numeric' => !empty($this->definition['numeric']),
          ),
        );
      }
    }
    return $this->add_table($join);
  }
}