我試圖執行PHP/MySQL的備份備份用PHP整個數據庫/ MYSQL
我從表單頁面接收值,然後使用命令「選擇表」,我保存一個陣列中的這些值。
後,我做了一個「for」循環備份每個表:
<?php
$dbname = $_POST['txt_db_name'];
$tbname = $_POST['txt_tb_name'];
$ligacao=mysql_connect('localhost','root','')
or die ('Problemas na ligação ao Servidor de MySQL');
$res = mysql_query("SHOW TABLES FROM pessoal");
$tables = array();
mysql_select_db($dbname,$ligacao);
while($row = mysql_fetch_array($res, MYSQL_NUM)) {
$tables[] = "$row[0]";
}
$length = count($tables);
for ($i = 0; $i < $length; $i++) {
$query=
"SELECT * INTO OUTFILE 'pessoa_Out.txt'".
"FIELDS TERMINATED BY ',' ".
"ENCLOSED BY '\"'".
"LINES TERMINATED BY '#'".
"FROM $tables[$i]";
$resultado = mysql_query($query,$ligacao);
}
mysql_close();
if ($resultado)
$msg ='Sucesso na Exportaçao da Database '.$dbname.' ';
else
$msg ='Erro Impossivel Exportar a Database '.$tbname.' ';
?>
您的問題是什麼......>? – 2013-03-25 10:50:59
http://sypex.net/en/ – 2013-03-25 11:04:05