lib/Doctrine/DBAL/Schema/Table.php
public function addNamedForeignKeyConstraint($name, $foreignTable, array $localColumnNames, array $foreignColumnNames, array $options = [])
    {
        if ($foreignTable instanceof Table) {
            foreach ($foreignColumnNames as $columnName) {
                if (! $foreignTable->hasColumn($columnName)) {
                    throw SchemaException::columnDoesNotExist($columnName, $foreignTable->getName());
                }
            }
        }

        foreach ($localColumnNames as $columnName) {
            if (! $this->hasColumn($columnName)) {
                throw SchemaException::columnDoesNotExist($columnName, $this->_name);
            }
        }

        $constraint = new ForeignKeyConstraint(
            $localColumnNames,
            $foreignTable,
            $foreignColumnNames,
            $name,
            $options
        );
        $this->_addForeignKeyConstraint($constraint);

        return $this;
    }
public function addNamedForeignKeyConstraint($name, $foreignTable, array $localColumnNames, array $foreignColumnNames, array $options = [])
    {
        if ($foreignTable instanceof Table) {
            foreach ($foreignColumnNames as $columnName) {
                if (! $foreignTable->hasColumn($columnName)) {
                    throw SchemaException::columnDoesNotExist($columnName, $foreignTable->getName());
                }
            }
        }

        foreach ($localColumnNames as $columnName) {
            if (! $this->hasColumn($columnName)) {
                throw SchemaException::columnDoesNotExist($columnName, $this->_name);
            }
        }

        $constraint = new ForeignKeyConstraint(
            $localColumnNames,
            $foreignTable,
            $foreignColumnNames,
            $name,
            $options
        );
        $this->_addForeignKeyConstraint($constraint);

        return $this;
    }
public function addNamedForeignKeyConstraint ( $ name , $ foreignTable , array $ localColumnNames , array $ foreignColumnNames , array $ options = [ ] ) { if ( $ foreignTable instanceof Table ) { foreach ( $ foreignColumnNames as $ columnName ) { if ( ! $ foreignTable -> hasColumn ( $ columnName ) ) { throw SchemaException :: columnDoesNotExist ( $ columnName , $ foreignTable -> getName ( ) ) ; } } } foreach ( $ localColumnNames as $ columnName ) { if ( ! $ this -> hasColumn ( $ columnName ) ) { throw SchemaException :: columnDoesNotExist ( $ columnName , $ this -> _name ) ; } } $ constraint = new ForeignKeyConstraint ( $ localColumnNames , $ foreignTable , $ foreignColumnNames , $ name , $ options ) ; $ this -> _addForeignKeyConstraint ( $ constraint ) ; return $ this ; }
Adds a foreign key constraint with a given name.

@deprecated Use {@link addForeignKeyConstraint}

@param string       $name
@param Table|string $foreignTable       Table schema instance or table name
@param string[]     $localColumnNames
@param string[]     $foreignColumnNames
@param mixed[]      $options

@return self

@throws SchemaException
Adds a foreign key constraint with a given name .