$tableName = str_replace('`', '', $tableArray[2]);
// Debug log
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sql=' . $sql . ',tableName=' . $tableName);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sql=' . $sql . ',tableName=' . $tableName . ',tableArray=<pre>' . print_r($tableArray, true) . '</pre>');
// Shall we add/drop?
if (((strpos($sql, 'ADD') !== false) || (strpos($sql, 'DROP') !== false) || (strpos($sql, 'CHANGE') !== false)) && ($noIndex === true)) {
// Skip this query silently because InnoDB does not understand fulltext indexes
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, sprintf("Skipped FULLTEXT: sql=%s,tableName=%s,hasZeroNums=%d,file=%s,line=%s", $sql, $tableName, intval((is_bool($result)) ? 0 : isSqlTableColumnFound($columnName)), $F, $L));
} elseif ($noIndex === false) {
- // And column name as well
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableArray=<pre>' . print_r($tableArray, true) . '</pre>');
+ // And column name as well without backticks
$keyName = str_replace('`', '', $tableArray[5]);
+ /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyName=' . $keyName . ',tableArray=<pre>' . print_r($tableArray, true) . '</pre>');
// Is this "UNIQUE" or so? FULLTEXT has been handled the elseif() block above
- if (in_array(strtoupper($keyName), array('INDEX', 'UNIQUE', 'KEY', 'FULLTEXT'))) {
+ if (in_array(strtoupper($tableArray[4]), array('INDEX', 'UNIQUE', 'KEY', 'FULLTEXT'))) {
// Init loop
- $begin = 1; $keyName = ',';
+ $begin = 1;
+ $keyName = ',';
while (strpos($keyName, ',') !== false) {
// Use last
$keyName = str_replace('`', '', $tableArray[count($tableArray) - $begin]);
} // END - if
// Shall we run it?
- if (!isSqlTableIndexAdded($tableName, $tableArray[3], $keyName)) {
- // Send it to the SQL_QUERY() function
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $sql);
+ /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ', tableArray[3]=' . $tableArray[3] . ',keyName=' . $keyName);
+ if ((!isSqlTableIndexAdded($tableName, $tableArray[3], $keyName)) && ($tableArray[3] == 'ADD')) {
+ // Send it to the SQL_QUERY() function to add it
+ /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $sql);
+ $result = SQL_QUERY($sql, $F, $L, $enableCodes);
+ } elseif ((isSqlTableIndexAdded($tableName, $tableArray[3], $keyName)) && ($tableArray[3] == 'DROP')) {
+ // Send it to the SQL_QUERY() function to drop it
+ /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $sql);
$result = SQL_QUERY($sql, $F, $L, $enableCodes);
} else {
// Not executed
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Not executed: ' . $sql);
+ /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Not executed: ' . $sql);
}
} else {
// Other ALTER TABLE query