public function &setJoinTable($table_name, $join_field = null)
    {
        $this->join_table = $table_name;

        if (empty($this->target_join_field)) {
            if (is_string($join_field) && $join_field) {
                $this->setTargetJoinField($join_field);
            } elseif (is_array($join_field)) {
                if (count($join_field) == 2 && !empty($join_field[0]) && !empty($join_field[1])) {
                    $this->setSourceJoinField($join_field[0]);
                    $this->setTargetJoinField($join_field[1]);
                } else {
                    throw new InvalidArgumentException('Join field should be an array with two elements');
                }
            } else {
                $registered_type = $this->getRegisteredType();

                if (($pos = strrpos($registered_type, '\\')) !== false) {
                    $this->target_join_field = Inflector::singularize(Inflector::tableize(substr($registered_type, $pos + 1))) . '_id';
                } else {
                    $this->target_join_field = Inflector::singularize(Inflector::tableize($registered_type)) . '_id';
                }
            }
        }

        return $this;
    }
public function &setJoinTable($table_name, $join_field = null)
    {
        $this->join_table = $table_name;

        if (empty($this->target_join_field)) {
            if (is_string($join_field) && $join_field) {
                $this->setTargetJoinField($join_field);
            } elseif (is_array($join_field)) {
                if (count($join_field) == 2 && !empty($join_field[0]) && !empty($join_field[1])) {
                    $this->setSourceJoinField($join_field[0]);
                    $this->setTargetJoinField($join_field[1]);
                } else {
                    throw new InvalidArgumentException('Join field should be an array with two elements');
                }
            } else {
                $registered_type = $this->getRegisteredType();

                if (($pos = strrpos($registered_type, '\\')) !== false) {
                    $this->target_join_field = Inflector::singularize(Inflector::tableize(substr($registered_type, $pos + 1))) . '_id';
                } else {
                    $this->target_join_field = Inflector::singularize(Inflector::tableize($registered_type)) . '_id';
                }
            }
        }

        return $this;
    }
public function & setJoinTable ( $ table_name , $ join_field = null ) { $ this -> join_table = $ table_name ; if ( empty ( $ this -> target_join_field ) ) { if ( is_string ( $ join_field ) && $ join_field ) { $ this -> setTargetJoinField ( $ join_field ) ; } elseif ( is_array ( $ join_field ) ) { if ( count ( $ join_field ) == 2 && ! empty ( $ join_field [ 0 ] ) && ! empty ( $ join_field [ 1 ] ) ) { $ this -> setSourceJoinField ( $ join_field [ 0 ] ) ; $ this -> setTargetJoinField ( $ join_field [ 1 ] ) ; } else { throw new InvalidArgumentException ( 'Join field should be an array with two elements' ) ; } } else { $ registered_type = $ this -> getRegisteredType ( ) ; if ( ( $ pos = strrpos ( $ registered_type , '\\' ) ) !== false ) { $ this -> target_join_field = Inflector :: singularize ( Inflector :: tableize ( substr ( $ registered_type , $ pos + 1 ) ) ) . '_id' ; } else { $ this -> target_join_field = Inflector :: singularize ( Inflector :: tableize ( $ registered_type ) ) . '_id' ; } } } return $ this ; }
Set join table name.

If $join_field is null, join field will be based on model name. There are two ways to specify it:

1. As string, where value is for target field and it will map with ID column of the source table,
2. As array, where first element is ID in the source table and second element is field in target table

@param  string            $table_name
@param  array|string|null $join_field
@return $this
Set join table name .