src/Query.php
public function join(Table $table, $joined_table_column, $column, $criteria = [], $join_type = Join::LEFT, $on_table = null)
        {
            if (!$this->table instanceof Table) {
                throw new Exception('Cannot use ' . $this->table . ' as a table. You need to call setTable() before trying to join a new table');
            }

            if (!$table instanceof Table) {
                throw new Exception('Cannot join table ' . $table . ' since it is not a table');
            }

            foreach ($this->joins as $join) {
                if ($join->getTable()->getB2DBAlias() === $table->getB2DBAlias()) {
                    $table = clone $table;
                    break;
                }
            }

            $left_column = $table->getB2DBAlias() . '.' . Table::getColumnName($joined_table_column);
            $join_on_table = $on_table ?? $this->table;
            $right_column = $join_on_table->getB2DBAlias() . '.' . Table::getColumnName($column);

            $this->joins[$table->getB2DBAlias()] = new Join($table, $left_column, $right_column, $this->getRealColumnName($column), $criteria, $join_type);

            return $table;
        }
public function join(Table $table, $joined_table_column, $column, $criteria = [], $join_type = Join::LEFT, $on_table = null)
        {
            if (!$this->table instanceof Table) {
                throw new Exception('Cannot use ' . $this->table . ' as a table. You need to call setTable() before trying to join a new table');
            }

            if (!$table instanceof Table) {
                throw new Exception('Cannot join table ' . $table . ' since it is not a table');
            }

            foreach ($this->joins as $join) {
                if ($join->getTable()->getB2DBAlias() === $table->getB2DBAlias()) {
                    $table = clone $table;
                    break;
                }
            }

            $left_column = $table->getB2DBAlias() . '.' . Table::getColumnName($joined_table_column);
            $join_on_table = $on_table ?? $this->table;
            $right_column = $join_on_table->getB2DBAlias() . '.' . Table::getColumnName($column);

            $this->joins[$table->getB2DBAlias()] = new Join($table, $left_column, $right_column, $this->getRealColumnName($column), $criteria, $join_type);

            return $table;
        }
public function join ( Table $ table , $ joined_table_column , $ column , $ criteria = [ ] , $ join_type = Join :: LEFT , $ on_table = null ) { if ( ! $ this -> table instanceof Table ) { throw new Exception ( 'Cannot use ' . $ this -> table . ' as a table. You need to call setTable() before trying to join a new table' ) ; } if ( ! $ table instanceof Table ) { throw new Exception ( 'Cannot join table ' . $ table . ' since it is not a table' ) ; } foreach ( $ this -> joins as $ join ) { if ( $ join -> getTable ( ) -> getB2DBAlias ( ) === $ table -> getB2DBAlias ( ) ) { $ table = clone $ table ; break ; } } $ left_column = $ table -> getB2DBAlias ( ) . '.' . Table :: getColumnName ( $ joined_table_column ) ; $ join_on_table = $ on_table ?? $ this -> table ; $ right_column = $ join_on_table -> getB2DBAlias ( ) . '.' . Table :: getColumnName ( $ column ) ; $ this -> joins [ $ table -> getB2DBAlias ( ) ] = new Join ( $ table , $ left_column , $ right_column , $ this -> getRealColumnName ( $ column ) , $ criteria , $ join_type ) ; return $ table ; }
Join one table on another

@param Table $table The table to join
@param string $joined_table_column The left matching column
@param string $column The right matching column
@param Criteria[] $criteria An array of criteria (ex: array(array(DB_FLD_ISSUE_ID, 1), array(DB_FLD_ISSUE_STATE, 1));
@param string $join_type Type of join
@param Table $on_table If different than the main table, specify the left side of the join here

@return Table
Join one table on another