Granada\ORM::_add_join_source PHP Method

_add_join_source() protected method

The join_operator should be one of INNER, LEFT OUTER, CROSS etc - this will be prepended to JOIN. The table should be the name of the table to join to. The constraint may be either a string or an array with three elements. If it is a string, it will be compiled into the query as-is, with no escaping. The recommended way to supply the constraint is as an array with three elements: first_column, operator, second_column Example: array('user.id', '=', 'profile.user_id') will compile to ON user.id = profile.user_id The final (optional) argument specifies an alias for the joined table.
protected _add_join_source ( string $join_operator, $table, $constraint, $table_alias = null )
$join_operator string
    protected function _add_join_source($join_operator, $table, $constraint, $table_alias = null)
    {
        $join_operator = trim("{$join_operator} JOIN");
        $table = $this->_quote_identifier($table);
        // Add table alias if present
        if (!is_null($table_alias)) {
            $table_alias = $this->_quote_identifier($table_alias);
            $table .= " {$table_alias}";
        }
        // Build the constraint
        if (is_array($constraint)) {
            list($first_column, $operator, $second_column) = $constraint;
            $first_column = $this->_quote_identifier($first_column);
            $second_column = $this->_quote_identifier($second_column);
            $constraint = "{$first_column} {$operator} {$second_column}";
        }
        $this->_join_sources[] = "{$join_operator} {$table} ON {$constraint}";
        return $this;
    }
ORM