You are here

function views_field_join::build_multi_join in Views Field 7

1 call to views_field_join::build_multi_join()
views_field_join::build_join in ./views_field.join.inc
Build the SQL for the join this object represents.

File

./views_field.join.inc, line 116
Provides a multi-column join on field tables.

Class

views_field_join
A function class to represent a multi-column join and create the SQL necessary to implement the join.

Code

function build_multi_join($table, $view_query) {

  // Handle either join field not being an array.
  // @todo Handle item counts not the same.
  if (!is_array($this->left_field)) {
    $this->left_field = array(
      $this->left_field,
    );
  }
  if (!is_array($this->field)) {
    $this->field = array(
      $this->field,
    );
  }
  $conditions = array();
  foreach ($this->left_field as $key => $left_field) {
    if ($this->left_table) {
      $left = $view_query
        ->get_table_info($this->left_table);
      $left_field = "{$left['alias']}.{$left_field}";
    }

    //       else {
    //         // This can be used if left_field is a formula or something. It should be used only *very* rarely.
    //         $left_field = $left_field;
    //       }
    $conditions[] = "{$left_field} = {$table['alias']}.{$this->field[$key]}";
  }
  return implode(' AND ', $conditions);
}