- if (((ereg("ADD", $sql)) || (ereg("DROP", $sql))) && ($noIndex)) {
- // And column name as well
- $columnName = str_replace("`", '', $tableArray[4]);
-
- // Get column information
- $result = SQL_QUERY_ESC("SHOW COLUMNS FROM %s LIKE '%s'",
- array($tableName, $columnName), __FILE__, __LINE__);
-
- // Do we have no entry on ADD or an entry on DROP?
- // 123 4 4 3 3 4 432 23 4 4 3 3 4 4321
- if (((SQL_NUMROWS($result) == 0) && (ereg("ADD", $sql))) || ((SQL_NUMROWS($result) == 1) && (ereg("DROP", $sql)))) {
- // Do the query
- //* DEBUG: */ print __LINE__.":".$sql."<br />\n";
- $result = SQL_QUERY($sql, $F, $L, false);
- } // END - if
- } elseif ((constant('_TABLE_TYPE') == "InnoDB") && (ereg("FULLTEXT", $sql))) {
+ if (((strpos($sql, 'ADD') !== false) || (strpos($sql, 'DROP') !== false)) && ($noIndex === true)) {
+ // Try two columns, one should fix
+ foreach (array(4,5) as $idx) {
+ // And column name as well
+ $columnName = str_replace('`', '', $tableArray[$idx]);
+
+ // Get column information
+ $result = SQL_QUERY_ESC("SHOW COLUMNS FROM `%s` LIKE '%s'",
+ array($tableName, $columnName), __FILE__, __LINE__);
+
+ // Do we have no entry on ADD or an entry on DROP?
+ // 123 4 4 3 3 4 4 32 23 4 4 3 3 4 4 321
+ if (((SQL_HASZERONUMS($result)) && (strpos($sql, 'ADD') !== false)) || ((SQL_NUMROWS($result) == 1) && (strpos($sql, 'DROP') !== false))) {
+ // Do the query
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Executing: ' . $sql);
+ $result = SQL_QUERY($sql, $F, $L, false);
+
+ // Skip further attempt(s)
+ break;
+ } elseif ((((SQL_NUMROWS($result) == 1) && (strpos($sql, 'ADD') !== false)) || ((SQL_HASZERONUMS($result)) && (strpos($sql, 'DROP') !== false))) && ($columnName != 'KEY')) {
+ // Abort here because it is alreay there
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Skipped: ' . $sql);
+ break;
+ } elseif ($columnName != 'KEY') {
+ // Something didn't fit
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Possible problem: ' . $sql);
+ }
+ } // END - foreach
+ } elseif ((getConfig('_TABLE_TYPE') == 'InnoDB') && (strpos($sql, 'FULLTEXT') !== false)) {