source/Core/DbMetaDataHandler.php
public function getAddFieldIndexSql($table, $field, $newField, $tableSet = null)
    {
        $res = \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->getAll("show create table {$table}");

        $tableSql = $res[0][1];

        preg_match_all("/([\w]+\s+)?\bKEY\s+(`[^`]+`)?\s*\([^)]+(\(\d++\))*\)/iU", $tableSql, $match);
        $index = $match[0];

        $usingTableSet = $tableSet ? true : false;

        if (!$tableSet) {
            $tableSet = $table;
        }

        $indexQueries = [];
        $sql = [];
        if (count($index)) {
            foreach ($index as $key => $indexQuery) {
                if (preg_match("/\([^)]*\b" . $field . "\b[^)]*\)/i", $indexQuery)) {
                    //removing index name - new will be added automaticly
                    $indexQuery = preg_replace("/(.*\bKEY\s+)`[^`]+`/", "$1", $indexQuery);

                    if ($usingTableSet) {
                        // replacing multiple fields to one (#3269)
                        $indexQuery = preg_replace("/\([^\)]+\)+/", "(`$newField`{$match[3][$key]})", $indexQuery);
                    } else {
                        //replacing previous field name with new one
                        $indexQuery = preg_replace("/\b" . $field . "\b/", $newField, $indexQuery);
                    }
                    $indexQueries[] = "ADD " . $indexQuery;
                }
            }
            if (count($indexQueries)) {
                $sql = ["ALTER TABLE `$tableSet` " . implode(", ", $indexQueries)];
            }
        }

        return $sql;
    }
public function getAddFieldIndexSql($table, $field, $newField, $tableSet = null)
    {
        $res = \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->getAll("show create table {$table}");

        $tableSql = $res[0][1];

        preg_match_all("/([\w]+\s+)?\bKEY\s+(`[^`]+`)?\s*\([^)]+(\(\d++\))*\)/iU", $tableSql, $match);
        $index = $match[0];

        $usingTableSet = $tableSet ? true : false;

        if (!$tableSet) {
            $tableSet = $table;
        }

        $indexQueries = [];
        $sql = [];
        if (count($index)) {
            foreach ($index as $key => $indexQuery) {
                if (preg_match("/\([^)]*\b" . $field . "\b[^)]*\)/i", $indexQuery)) {
                    //removing index name - new will be added automaticly
                    $indexQuery = preg_replace("/(.*\bKEY\s+)`[^`]+`/", "$1", $indexQuery);

                    if ($usingTableSet) {
                        // replacing multiple fields to one (#3269)
                        $indexQuery = preg_replace("/\([^\)]+\)+/", "(`$newField`{$match[3][$key]})", $indexQuery);
                    } else {
                        //replacing previous field name with new one
                        $indexQuery = preg_replace("/\b" . $field . "\b/", $newField, $indexQuery);
                    }
                    $indexQueries[] = "ADD " . $indexQuery;
                }
            }
            if (count($indexQueries)) {
                $sql = ["ALTER TABLE `$tableSet` " . implode(", ", $indexQueries)];
            }
        }

        return $sql;
    }
public function getAddFieldIndexSql ( $ table , $ field , $ newField , $ tableSet = null ) { $ res = \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( ) -> getAll ( "show create table {$table}" ) ; $ tableSql = $ res [ 0 ] [ 1 ] ; preg_match_all ( "/([\w]+\s+)?\bKEY\s+(`[^`]+`)?\s*\([^)]+(\(\d++\))*\)/iU" , $ tableSql , $ match ) ; $ index = $ match [ 0 ] ; $ usingTableSet = $ tableSet ? true : false ; if ( ! $ tableSet ) { $ tableSet = $ table ; } $ indexQueries = [ ] ; $ sql = [ ] ; if ( count ( $ index ) ) { foreach ( $ index as $ key => $ indexQuery ) { if ( preg_match ( "/\([^)]*\b" . $ field . "\b[^)]*\)/i" , $ indexQuery ) ) { //removing index name - new will be added automaticly $ indexQuery = preg_replace ( "/(.*\bKEY\s+)`[^`]+`/" , "$1" , $ indexQuery ) ; if ( $ usingTableSet ) { // replacing multiple fields to one (#3269) $ indexQuery = preg_replace ( "/\([^\)]+\)+/" , "(`$newField`{$match[3][$key]})" , $ indexQuery ) ; } else { //replacing previous field name with new one $ indexQuery = preg_replace ( "/\b" . $ field . "\b/" , $ newField , $ indexQuery ) ; } $ indexQueries [ ] = "ADD " . $ indexQuery ; } } if ( count ( $ indexQueries ) ) { $ sql = [ "ALTER TABLE `$tableSet` " . implode ( ", " , $ indexQueries ) ] ; } } return $ sql ; }
Get sql for new multi-language field index creation

@param string $table    core table name
@param string $field    field name
@param string $newField new field name
@param string $tableSet table to change (if not set take core table)

@return string
Get sql for new multi - language field index creation