Code Duplication    Length = 26-26 lines in 2 locations

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

@@ 766-791 (lines=26) @@
763
     * @param string $tableName Table Name
764
     * @return array
765
     */
766
    protected function getForeignKeys($tableName)
767
    {
768
        $foreignKeys = [];
769
        $rows = $this->fetchAll(sprintf(
770
            "SELECT
771
              CONSTRAINT_NAME,
772
              TABLE_NAME,
773
              COLUMN_NAME,
774
              REFERENCED_TABLE_NAME,
775
              REFERENCED_COLUMN_NAME
776
            FROM information_schema.KEY_COLUMN_USAGE
777
            WHERE REFERENCED_TABLE_SCHEMA = DATABASE()
778
              AND REFERENCED_TABLE_NAME IS NOT NULL
779
              AND TABLE_NAME = '%s'
780
            ORDER BY POSITION_IN_UNIQUE_CONSTRAINT",
781
            $tableName
782
        ));
783
        foreach ($rows as $row) {
784
            $foreignKeys[$row['CONSTRAINT_NAME']]['table'] = $row['TABLE_NAME'];
785
            $foreignKeys[$row['CONSTRAINT_NAME']]['columns'][] = $row['COLUMN_NAME'];
786
            $foreignKeys[$row['CONSTRAINT_NAME']]['referenced_table'] = $row['REFERENCED_TABLE_NAME'];
787
            $foreignKeys[$row['CONSTRAINT_NAME']]['referenced_columns'][] = $row['REFERENCED_COLUMN_NAME'];
788
        }
789
790
        return $foreignKeys;
791
    }
792
793
    /**
794
     * {@inheritdoc}

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

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