public static function tableForeignKeys($tableName)
    {
        $result = ['inner' => [], 'outer' => []];
        foreach (Yii::$app->db->schema->tableSchemas as $table) {
            $foreignKeys = static::findConstraints($table);
            /** @var TableSchema $table */
            if ($table->name == $tableName) {
                $result['inner'] = $foreignKeys;
                continue;
            }
            foreach ($foreignKeys as $foreignKey) {
                if ($foreignKey['ftable'] == $tableName) {
                    $result['outer'][] = $foreignKey;
                }
            }
        }
        return $result;
    }
public static function tableForeignKeys($tableName)
    {
        $result = ['inner' => [], 'outer' => []];
        foreach (Yii::$app->db->schema->tableSchemas as $table) {
            $foreignKeys = static::findConstraints($table);
            /** @var TableSchema $table */
            if ($table->name == $tableName) {
                $result['inner'] = $foreignKeys;
                continue;
            }
            foreach ($foreignKeys as $foreignKey) {
                if ($foreignKey['ftable'] == $tableName) {
                    $result['outer'][] = $foreignKey;
                }
            }
        }
        return $result;
    }
public static function tableForeignKeys ( $ tableName ) { $ result = [ 'inner' => [ ] , 'outer' => [ ] ] ; foreach ( Yii :: $ app -> db -> schema -> tableSchemas as $ table ) { $ foreignKeys = static :: findConstraints ( $ table ) ; /** @var TableSchema $table */ if ( $ table -> name == $ tableName ) { $ result [ 'inner' ] = $ foreignKeys ; continue ; } foreach ( $ foreignKeys as $ foreignKey ) { if ( $ foreignKey [ 'ftable' ] == $ tableName ) { $ result [ 'outer' ] [ ] = $ foreignKey ; } } } return $ result ; }
Finds all foreign keys in the table and related to the table column from outer tables.
@param $tableName
@return array ['inner'=>[], 'outer'=>[]]
Finds all foreign keys in the table and related to the table column from outer tables .