You are here

function menu_node_views_relationship_double::query in Menu Node Views 7.2

Called to implement a relationship in a query.

Overrides views_handler_relationship::query

File

includes/menu_node_views_relationship_double.inc, line 76

Class

menu_node_views_relationship_double
Relationship handler to create a double jointure, ie through 2 tables: from the base table to the final table through the relation table

Code

function query() {

  // Figure out what base table this relationship brings to the party.
  $this
    ->ensure_my_table();
  $middle_table = $this->query
    ->add_table($this->definition['middle_table'], $this->relationship);
  $def['table'] = $this->definition['right_table'];
  $def['left_table'] = $middle_table;
  $def['left_field'] = $this->definition['middle_field_2'];
  $def['field'] = $this->definition['right_field_2'];
  $def['type'] = empty($this->options['required']) ? 'LEFT' : 'INNER';
  $join = new views_join();
  $join->definition = $def;
  $join
    ->construct();
  $join->adjusted = TRUE;

  // use a short alias for this:
  $alias = $def['table'] . '_' . $this->table;
  $this->alias = $this->query
    ->add_relationship($alias, $join, $this->definition['right_table'], $this->relationship);
}