function views_join::construct

Same name in other branches
  1. 7.x-3.x includes/handlers.inc \views_join::construct()

Construct the views_join object.

File

includes/handlers.inc, line 1590

Class

views_join
A function class to represent a join and create the SQL necessary to implement the join.

Code

function construct($table = NULL, $left_table = NULL, $left_field = NULL, $field = NULL, $extra = array(), $type = 'LEFT') {
    $this->extra_type = 'AND';
    if (!empty($table)) {
        $this->table = $table;
        $this->left_table = $left_table;
        $this->left_field = $left_field;
        $this->field = $field;
        $this->extra = $extra;
        $this->type = strtoupper($type);
    }
    else {
        if (!empty($this->definition)) {
            // if no arguments, construct from definition.
            // These four must exist or it will throw notices.
            $this->table = $this->definition['table'];
            $this->left_table = $this->definition['left_table'];
            $this->left_field = $this->definition['left_field'];
            $this->field = $this->definition['field'];
            if (!empty($this->definition['extra'])) {
                $this->extra = $this->definition['extra'];
            }
            if (!empty($this->definition['extra type'])) {
                $this->extra_type = strtoupper($this->definition['extra type']);
            }
            $this->type = !empty($this->definition['type']) ? strtoupper($this->definition['type']) : 'LEFT';
        }
    }
}