// Disable Keys of actual table (after page-refresh: again!)
// to speed up restoring
// but only if the table should be restored and if it already exists
$existingTables = $dbo->getTables($config['db_actual']);
$actualTable = $restore['actual_table'];
if (in_array($actualTable, $existingTables)) {
    if ($restore['tables_to_restore']) {
        if (in_array($actualTable, $restore['tables_to_restore'])) {
            Sql::disableKeys($dbo, $restore['actual_table']);
        }
    } elseif ($actualTable > '' && $actualTable != 'unbekannt') {
        Sql::disableKeys($dbo, $restore['actual_table']);
    }
}
while ($commandsFound < $restore['speed'] && $timeElapsed < $restore['max_zeit'] && !$restore['fileEOF'] && !$restore['EOB']) {
    $sqlCommand = getQueryFromFile();
    $commandsFound++;
    if ($sqlCommand > '') {
        //$log->write(Log::PHP, $sqlCommand);
        try {
            $res = $dbo->query($sqlCommand, MsdDbFactory::SIMPLE);
            // get nr of affected rows
            $command = strtoupper(substr($sqlCommand, 0, 7));
            if ($command == 'INSERT ' || $command == 'REPLACE') {
                $rowsAffected = $dbo->getAffectedRows();
                $restore['records_inserted'] += $rowsAffected;
                if (!isset($restore['records_inserted_table'][$restore['actual_table']])) {
                    $restore['records_inserted_table'][$restore['actual_table']] = 0;
                }
                $restore['records_inserted_table'][$restore['actual_table']] += $rowsAffected;
            }
 $restore['page_refreshs'] = 0;
 $restore['table_ready'] = 0;
 $restore['errors'] = 0;
 $restore['notices'] = 0;
 $restore['actual_fieldcount'] = 0;
 $restore['records_inserted'] = 0;
 $restore['records_inserted_table'] = array();
 $restore['extended_inserts'] = 0;
 $restore['extended_insert_flag'] = -1;
 $restore['last_parser_status'] = 0;
 $restore['EOB'] = false;
 $restore['fileEOF'] = false;
 $restore['tables_to_restore'] = false;
 // restore complete file
 do {
     $query = getQueryFromFile(false);
     if (!is_array($query)) {
         $queries[] = $query;
     } else {
         // error in Query
         $error[] = $query[1];
         break;
     }
 } while (!$restore['fileEOF']);
 // close and remove temp file after the job is done
 fclose($restore['filehandle']);
 @unlink($config['paths']['backup'] . $fileName);
 if (isset($_POST['tablecombo']) && $_POST['tablecombo'] > '') {
     $sql['sql_statements'] = $_POST['tablecombo'];
     $tablename = extractTablenameFromSQL($sql['sql_statements']);
 }