예제 #1
0
function get_content($db, $table)
{
    global $config, $nl, $dump, $buffer;
    $content = '';
    $complete = Fieldlist($db, $table) . ' ';
    $table_ready = 0;
    $query = 'SELECT * FROM `' . $table . '` LIMIT ' . $dump['zeilen_offset'] . ',' . ($dump['restzeilen'] + 1);
    (bool) mysqli_query($GLOBALS["___mysqli_ston"], "USE " . $db);
    $result = mysqli_query($config['dbconnection'], $query);
    $ergebnisse = @mysqli_num_rows($result);
    if ($ergebnisse !== false) {
        $num_felder = ($___mysqli_tmp = mysqli_num_fields($result)) ? $___mysqli_tmp : false;
        $first = 1;
        if ($ergebnisse > $dump['restzeilen']) {
            $dump['zeilen_offset'] += $dump['restzeilen'];
            $ergebnisse--;
            $dump['restzeilen'] = 0;
        } else {
            $dump['table_offset']++;
            $dump['zeilen_offset'] = 0;
            $dump['restzeilen'] = $dump['restzeilen'] - $ergebnisse;
            $table_ready = 1;
        }
        $ax = 0;
        for ($x = 0; $x < $ergebnisse; $x++) {
            $row = mysqli_fetch_row($result);
            $ax++;
            $insert = 'INSERT INTO `' . $table . '` ' . $complete . 'VALUES (';
            for ($j = 0; $j < $num_felder; $j++) {
                if (!isset($row[$j])) {
                    $insert .= 'NULL,';
                } else {
                    if ($row[$j] != '') {
                        $insert .= '\'' . mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $row[$j]) . '\',';
                    } else {
                        $insert .= '\'\',';
                    }
                }
            }
            $insert = substr($insert, 0, -1) . ');' . $nl;
            $dump['data'] .= $insert;
            $dump['countdata']++;
            if (strlen($dump['data']) > $config['memory_limit'] || $config['multi_part'] == 1 && strlen($dump['data']) + $buffer > $config['multipart_groesse']) {
                WriteToDumpFile();
            }
        }
        if ($table_ready == 1 && $dump['table_types'][getDBIndex($db, $table)] != 'VIEW') {
            $dump['data'] .= "/*!40000 ALTER TABLE `{$table}` ENABLE KEYS */;\n";
        }
    } else {
        // table corrupt -> skip it
        $dump['table_offset']++;
        $dump['zeilen_offset'] = 0;
        $dump['restzeilen'] = $dump['restzeilen'] - $ergebnisse;
        $dump['data'] .= "/*!40000 ALTER TABLE `{$table}` ENABLE KEYS */;\n";
        if (strlen($dump['data']) > $config['memory_limit'] || $config['multi_part'] == 1 && strlen($dump['data']) + $buffer > $config['multipart_groesse']) {
            WriteToDumpFile();
        }
    }
    @(mysqli_free_result($result) || is_object($result) && get_class($result) == "mysqli_result" ? true : false);
}
예제 #2
0
파일: dump.php 프로젝트: thaian2009/php
                 $read_create_error = sprintf($lang['L_FATAL_ERROR_DUMP'], $table, $adbname) . ': ' . mysql_error($config['dbconnection']);
                 Errorlog("DUMP", $databases['db_actual'], '', $read_create_error, 0);
                 WriteLog($read_create_error);
                 if ($config['stop_with_error'] > 0) {
                     die($read_create_error);
                 }
                 $dump['errors']++;
             }
         }
         WriteToDumpFile();
         if (!in_array($adbname . '|' . $table, $dump['skip_data']) && $dump['table_types'][getDBIndex($adbname, $table)] != 'VIEW') {
             get_content($adbname, $table);
             $dump['restzeilen']--;
         } else {
             // skip data
             if ($dump['table_types'][getDBIndex($adbname, $table)] != 'VIEW') {
                 $dump['data'] .= '/*!40000 ALTER TABLE `' . $table . '` ENABLE KEYS */;' . "\n";
             }
             WriteToDumpFile();
             $dump['table_offset']++;
         }
         if ($config['memory_limit'] > 0 && strlen($dump['data']) > $config['memory_limit']) {
             WriteToDumpFile();
         }
     }
 }
 /////////////////////////////////
 // Anzeige - Fortschritt
 /////////////////////////////////
 if ($config['multi_dump'] == 1) {
     $mudbs = '';