function create_backup_file($file_name_backup, $drop = false) {
$file = fopen($file_name_backup, 'w+');
$output = "# Czas wygenerowania: ".date('d-m-Y G:i')."\r\n"; $output .= "# Wersja php: ".phpversion()."\r\n\r\n";
$query = 'SHOW TABLES';
$struct_table[$table] = '';
$struct_table[$table] .= "\r\n\r\n# Struktura tabeli: ".$table."\r\n\r\n\r\n";
$query_struct_table = mysql_query("SHOW CREATE TABLE `$table`");
foreach($struct as $tbl)
if($drop) {
$struct_table[$table] .= 'DROP TABLE IF EXISTS `'.$table."`;\r\n";
$struct_table[$table] .= $tbl. ";\r\n\r\n";
}
else $struct_table[$table] .= $tbl. ";\r\n\r\n";
}
fwrite($file, $struct_table[$table]);
$table_zaw = "-------------------------------\r\n";
$table_zaw .= '-- Zawartosc tabeli: '.$table."\r\n";
$table_zaw .= "-------------------------------\r\n\r\n\r\n";
$col_names= '';
$col_names = substr($col_names, 0
, -2
);
$values = '';
for($i = 0; $i < $num; $i++) {
if($type == "tinyint" || $type == "smallint" || $type == "mediumint" || $type == "int" || $type == "bigint" || $type == "timestamp") $values.= $row2[$i].', '; else $values .= "'$row2[$i]'".', ';
}
$values = substr($values, 0
, -2
); $insert = "INSERT INTO ".$table."(".$col_names.") VALUES(".$values.");\r\n";
}
}
}
function download_file($file_backup) {
header('Content-type: application/x-unknown'); header('Content-Disposition: attachment; filename='.$file_backup); }
Moja funkcja jak wywolac chyba kazdy wie.