/** * Checks if in the chosen database are tables in conflict with the wcf tables * which will be created in the next step. * * @param Database $db * @param integer $dbNumber */ protected function getConflictedTables($db, $dbNumber) { // get content of the sql structure file $sql = file_get_contents(TMP_DIR . 'setup/db/install.sql'); // installation number value 'n' (WCF_N) must be reflected in the executed sql queries $sql = StringUtil::replace('wcf1_', 'wcf' . $dbNumber . '_', $sql); // get all tablenames which should be created preg_match_all("%CREATE\\s+TABLE\\s+(\\w+)%", $sql, $matches); // get all installed tables from chosen database $existingTables = $db->getEditor()->getTableNames(); // check if existing tables are in conflict with wcf tables $conflictedTables = array(); foreach ($existingTables as $existingTableName) { foreach ($matches[1] as $wcfTableName) { if ($existingTableName == $wcfTableName) { $conflictedTables[] = $wcfTableName; } } } return $conflictedTables; }