Returns string of foreign keys

@param    array    $foreign_keys       Array of foreign key rules
@return   string    the formated foreign key string
975356
public static function process_foreign_keys($foreign_keys, $db = null)
	{
		if ( ! is_array($foreign_keys))
		{
			throw new \Database_Exception('Foreign keys on create_table() must be specified as an array');
		}

		$fk_list = array();

		foreach($foreign_keys as $definition)
		{
			// some sanity checks
			if (empty($definition['key']))
			{
				throw new \Database_Exception('Foreign keys on create_table() must specify a foreign key name');
			}
			if ( empty($definition['reference']))
			{
				throw new \Database_Exception('Foreign keys on create_table() must specify a foreign key reference');
			}
			if (empty($definition['reference']['table']) or empty($definition['reference']['column']))
			{
				throw new \Database_Exception('Foreign keys on create_table() must specify a reference table and column name');
			}

			$sql = '';
			! empty($definition['constraint']) and $sql .= " CONSTRAINT ".\DB::quote_identifier($definition['constraint']);
			$sql .= " FOREIGN KEY (".\DB::quote_identifier($definition['key']).')';
			$sql .= " REFERENCES ".\DB::quote_identifier(\DB::table_prefix($definition['reference']['table'], static::$connection)).' (';
			if (is_array($definition['reference']['column']))
			{
				$sql .= implode(', ', \DB::quote_identifier($definition['reference']['column']));
			}
			else
			{
				$sql .= \DB::quote_identifier($definition['reference']['column']);
			}
			$sql .= ')';
			! empty($definition['on_update']) and $sql .= " ON UPDATE ".$definition['on_update'];
			! empty($definition['on_delete']) and $sql .= " ON DELETE ".$definition['on_delete'];

			$fk_list[] = "\n\t".ltrim($sql);
		}

		return ', '.implode(',', $fk_list);
	}
848538
public function getForeignKey()
    {
        if ($this->foreignKey !== null) {
            return $this->foreignKey;
        }
        $this->init();
        switch ($this->type) {
            case self::HAS_MANY:
            case self::HAS_ONE:
                return $this->owner->getTableName() . '_' . $this->owner->getPrimaryKey();
            case self::BELONGS_TO:
                return $this->foreign->getPrimaryKey();
            default:
                throw new \Exception(sprintf("Relation type '%s' is not supported.", $this->type));
        }
    }
1264811
static function TableKeyHasMany($table, $tablePKey, $foreignRef, $foreignKey = false, $foreignClass = 'ADODB_Active_Record')
	{
		if (!is_array($tablePKey)) {
			$tablePKey = array($tablePKey);
		}
		$ar = new ADODB_Active_Record($table,$tablePKey);
		$ar->hasMany($foreignRef, $foreignKey, $foreignClass);
	}
1185193
public function getForeignKey()
    {
        if ($this->_foreignKey === null) {
            $this->_foreignKey = $this->_modelKey($this->getSource()->getAlias());
        }

        return $this->_foreignKey;
    }
263238
public function getFkMemberElementDetails($memberFK, $objectFK, $fkClass, $fkTable) {
		$_fkClass = str_replace ( "\\", ".", $fkClass );
		$header = new HtmlHeader ( "", 4, $memberFK, "content" );
		if (is_array ( $objectFK ) || $objectFK instanceof \Traversable) {
			$header = $this->getFkHeaderListDetails ( $memberFK, $fkClass, $objectFK );
			$element = $this->getFkListDetails ( $memberFK, $fkClass, $objectFK );
			foreach ( $objectFK as $oItem ) {
				if (method_exists ( $oItem, "__toString" )) {
					$id = (CRUDHelper::getIdentifierFunction ( $fkClass )) ( 0, $oItem );
					$item = $element->addItem ( $oItem . "" );
					$item->setProperty ( "data-ajax", $_fkClass . "||" . $id );
					$item->addClass ( "showTable" );
					$this->onDisplayFkElementListDetails ( $item, $memberFK, $fkClass, $oItem );
				}
			}
		} else {
			if (method_exists ( $objectFK, "__toString" )) {
				$header = $this->getFkHeaderElementDetails ( $memberFK, $fkClass, $objectFK );
				$id = (CRUDHelper::getIdentifierFunction ( $fkClass )) ( 0, $objectFK );
				$element = $this->getFkElementDetails ( $memberFK, $fkClass, $objectFK );
				$element->setProperty ( "data-ajax", $_fkClass . "||" . $id )->addClass ( "showTable" );
			}
		}
		if (isset ( $element )) {
			return [ $header,$element ];
		}
		return null;
	}
29869
protected final function belongsTo($tableCls, $value_key = '', $foreign_key = '') {
        if (!$tableCls instanceof View) {
            $tableCls = new SimpleTable($tableCls, $this->dbconnection);
        }

        if (!$foreign_key) {
            $foreign_key = $tableCls->primaryKey;
        }

        if (!$value_key) {
            $value_key = $tableCls->foreignKey;
        }

        $sql = $tableCls->select();

        return [$sql, $foreign_key, $value_key, true, 'belongsTo'];
    }
1168775
protected function collectForeignKeys()
    {
        $keys = [];

        foreach ($this->info->relations as $relation) {

            if ( ! in_array(
                $relation->type,
                [ RelationType::BELONGS_TO, RelationType::MORPH_TO, RelationType::BELONGS_TO_THROUGH ]
            )) {
                continue;
            }

            $keys = array_merge($keys, $relation->foreign_keys);
        }

        return $keys;
    }
1134501
public function getForeignKey()
    {
        if (is_null($this->foreignKey)) {
            $name = $this->getParentEntityDescriptor()->getTableName();
            $this->foreignKey = "{$this->normalizeFieldName($name)}_id";
        }
        return $this->foreignKey;
    }
1130007
public function getMetaForignKeys(){
        $stmt = $this->query(self::META_FKEYS_SQL);
        if ($stmt === false){
            return array();
        }

        $keys = array();
        foreach ($stmt as $row){
            $keys[$row[0] . '.' . $row[1]] = $row[2] . '.' . $row[3];
        }

        return $keys;
    }
359895
public function getAddForeignKeyDDL(ForeignKey $fk)
    {
        if ($fk->isSkipSql() || $fk->isPolymorphic()) {
            return;
        }
        $pattern = "
ALTER TABLE %s ADD %s;
";

        return sprintf($pattern,
            $this->quoteIdentifier($fk->getTable()->getName()),
            $this->getForeignKeyDDL($fk)
        );
    }
340023
public function join(
        $foreign_table,
        $master_field = null,
        $join_kind = null,
        $_foreign_alias = null,
        $relation = null
    ) {
        if (!$_foreign_alias) {
            $_foreign_alias = '_'.$foreign_table[0];
        }
        $_foreign_alias = $this->_unique($this->relations, $_foreign_alias);

        /** @type SQL_Relation $rel */
        $rel = $this->add('SQL_Relation', $_foreign_alias);

        return $this->relations[$_foreign_alias] = $rel
            ->set($foreign_table, $master_field, $join_kind, $relation);
    }
1286973
public function leftJoin($foreign_table, $defaults = [])
    {
        if (!is_array($defaults)) {
            $defaults = ['master_field' => $defaults];
        }
        $defaults['weak'] = true;

        return $this->join($foreign_table, $defaults);
    }
109633
def _parent_foreign_key_mappings(cls):
        """"""
        parent_rel = cls.__mapper__.relationships.get(cls.export_parent)
        if parent_rel:
            return {l.name: r.name for (l, r) in parent_rel.local_remote_pairs}
        return {}
312848
protected function getForeignKeySQLDeclaration(ForeignKey $foreignKey)
    {
        if (!$this->supportForeignKeys()) {
            throw PlatformException::methodNotSupported(__METHOD__);
        }

        return 'CONSTRAINT '.$foreignKey->getName().
               ' FOREIGN KEY'.
               ' ('.implode(', ', $foreignKey->getLocalColumnNames()).')'.
               ' REFERENCES '.$foreignKey->getForeignTableName().
               ' ('.implode(', ', $foreignKey->getForeignColumnNames()).')'.
               ' ON DELETE '.$foreignKey->getOnDelete().
               ' ON UPDATE '.$foreignKey->getOnUpdate();
    }
412390
protected function fetchOneToMany($foreign_class, $foreign_column, $column)
    {
        return $foreign_class::select($this->connection)
            ->where($foreign_column, '=', $this->getRaw($column))
            ->execute();
    }
351404
def get_foreign_key(self, name):
        
        name = self._normalize_identifier(name)

        if not self.has_foreign_key(name):
            raise ForeignKeyDoesNotExist(name, self._name)

        return self._fk_constraints[name]
320235
protected function buildForeignKeyName($foreignKey, $baseTable)
    {
        return (is_null($foreignKey)) ?
            Inflector::singularize($baseTable).self::DEFAULT_FOREIGN_KEY_SUFFIX :
            $foreignKey;
    }