Code Duplication    Length = 26-26 lines in 2 locations

src/Phinx/Db/Adapter/SqlServerAdapter.php 1 location

@@ 920-945 (lines=26) @@
917
     * @param string $tableName Table Name
918
     * @return array
919
     */
920
    protected function getForeignKeys($tableName)
921
    {
922
        $foreignKeys = [];
923
        $rows = $this->fetchAll(sprintf(
924
            "SELECT
925
                    tc.constraint_name,
926
                    tc.table_name, kcu.column_name,
927
                    ccu.table_name AS referenced_table_name,
928
                    ccu.column_name AS referenced_column_name
929
                FROM
930
                    information_schema.table_constraints AS tc
931
                    JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name = kcu.constraint_name
932
                    JOIN information_schema.constraint_column_usage AS ccu ON ccu.constraint_name = tc.constraint_name
933
                WHERE constraint_type = 'FOREIGN KEY' AND tc.table_name = '%s'
934
                ORDER BY kcu.ordinal_position",
935
            $tableName
936
        ));
937
        foreach ($rows as $row) {
938
            $foreignKeys[$row['constraint_name']]['table'] = $row['table_name'];
939
            $foreignKeys[$row['constraint_name']]['columns'][] = $row['column_name'];
940
            $foreignKeys[$row['constraint_name']]['referenced_table'] = $row['referenced_table_name'];
941
            $foreignKeys[$row['constraint_name']]['referenced_columns'][] = $row['referenced_column_name'];
942
        }
943
944
        return $foreignKeys;
945
    }
946
947
    /**
948
     * {@inheritdoc}

src/Phinx/Db/Adapter/MysqlAdapter.php 1 location

@@ 783-808 (lines=26) @@
780
     * @param string $tableName Table Name
781
     * @return array
782
     */
783
    protected function getForeignKeys($tableName)
784
    {
785
        $foreignKeys = [];
786
        $rows = $this->fetchAll(sprintf(
787
            "SELECT
788
              CONSTRAINT_NAME,
789
              TABLE_NAME,
790
              COLUMN_NAME,
791
              REFERENCED_TABLE_NAME,
792
              REFERENCED_COLUMN_NAME
793
            FROM information_schema.KEY_COLUMN_USAGE
794
            WHERE REFERENCED_TABLE_SCHEMA = DATABASE()
795
              AND REFERENCED_TABLE_NAME IS NOT NULL
796
              AND TABLE_NAME = '%s'
797
            ORDER BY POSITION_IN_UNIQUE_CONSTRAINT",
798
            $tableName
799
        ));
800
        foreach ($rows as $row) {
801
            $foreignKeys[$row['CONSTRAINT_NAME']]['table'] = $row['TABLE_NAME'];
802
            $foreignKeys[$row['CONSTRAINT_NAME']]['columns'][] = $row['COLUMN_NAME'];
803
            $foreignKeys[$row['CONSTRAINT_NAME']]['referenced_table'] = $row['REFERENCED_TABLE_NAME'];
804
            $foreignKeys[$row['CONSTRAINT_NAME']]['referenced_columns'][] = $row['REFERENCED_COLUMN_NAME'];
805
        }
806
807
        return $foreignKeys;
808
    }
809
810
    /**
811
     * {@inheritdoc}