Code Duplication    Length = 26-26 lines in 2 locations

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

@@ 616-641 (lines=26) @@
613
     * @param string $tableName Table Name
614
     * @return array
615
     */
616
    protected function getForeignKeys($tableName)
617
    {
618
        $foreignKeys = [];
619
        $rows = $this->fetchAll(sprintf(
620
            "SELECT
621
              CONSTRAINT_NAME,
622
              TABLE_NAME,
623
              COLUMN_NAME,
624
              REFERENCED_TABLE_NAME,
625
              REFERENCED_COLUMN_NAME
626
            FROM information_schema.KEY_COLUMN_USAGE
627
            WHERE REFERENCED_TABLE_SCHEMA = DATABASE()
628
              AND REFERENCED_TABLE_NAME IS NOT NULL
629
              AND TABLE_NAME = '%s'
630
            ORDER BY POSITION_IN_UNIQUE_CONSTRAINT",
631
            $tableName
632
        ));
633
        foreach ($rows as $row) {
634
            $foreignKeys[$row['CONSTRAINT_NAME']]['table'] = $row['TABLE_NAME'];
635
            $foreignKeys[$row['CONSTRAINT_NAME']]['columns'][] = $row['COLUMN_NAME'];
636
            $foreignKeys[$row['CONSTRAINT_NAME']]['referenced_table'] = $row['REFERENCED_TABLE_NAME'];
637
            $foreignKeys[$row['CONSTRAINT_NAME']]['referenced_columns'][] = $row['REFERENCED_COLUMN_NAME'];
638
        }
639
640
        return $foreignKeys;
641
    }
642
643
    /**
644
     * {@inheritdoc}

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

@@ 793-818 (lines=26) @@
790
     * @param string $tableName Table Name
791
     * @return array
792
     */
793
    protected function getForeignKeys($tableName)
794
    {
795
        $foreignKeys = [];
796
        $rows = $this->fetchAll(sprintf(
797
            "SELECT
798
                    tc.constraint_name,
799
                    tc.table_name, kcu.column_name,
800
                    ccu.table_name AS referenced_table_name,
801
                    ccu.column_name AS referenced_column_name
802
                FROM
803
                    information_schema.table_constraints AS tc
804
                    JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name = kcu.constraint_name
805
                    JOIN information_schema.constraint_column_usage AS ccu ON ccu.constraint_name = tc.constraint_name
806
                WHERE constraint_type = 'FOREIGN KEY' AND tc.table_name = '%s'
807
                ORDER BY kcu.ordinal_position",
808
            $tableName
809
        ));
810
        foreach ($rows as $row) {
811
            $foreignKeys[$row['constraint_name']]['table'] = $row['table_name'];
812
            $foreignKeys[$row['constraint_name']]['columns'][] = $row['column_name'];
813
            $foreignKeys[$row['constraint_name']]['referenced_table'] = $row['referenced_table_name'];
814
            $foreignKeys[$row['constraint_name']]['referenced_columns'][] = $row['referenced_column_name'];
815
        }
816
817
        return $foreignKeys;
818
    }
819
820
    /**
821
     * {@inheritdoc}