• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • 用PHP實現XML備份Mysql數據庫

    發表于:2007-07-14來源:作者:點擊數: 標簽:
    以下是在 Linux 下通過Apache+ PHP 對Mysql 數據庫 的備份的文件代碼: 文件一、Listtable. php (文件列出數據庫中的所有表格,供選擇備份) 請選擇要備份的表格: $con= mysql _connect('localhost','root','xswlily'); $lists=mysql_list_tables(embed,$co


    以下是在Linux下通過Apache+PHP對Mysql數據庫的備份的文件代碼:

    文件一、Listtable.php (文件列出數據庫中的所有表格,供選擇備份)

    請選擇要備份的表格:
    $con=mysql_connect('localhost','root','xswlily');
    $lists=mysql_list_tables("embed",$con);
    //數據庫連接代碼
    $i=0;
    while($i$tb_name=mysql_tablename($lists,$i);
    echo "".$tb_name."
    ";
    //列出所有的表格
    $i++;}

    ?>

    文件二、Backup.php

    $con=mysql_connect('localhost','root','xswlily');
    $query="select * from $table ";
    //數據庫查詢
    $result=mysql_db_query("embed",$query,$con);
    $filestr="<"."?xml version="1.0" encoding="GB2312"?".">";
    $filestr.="<".$table."s>";
    while ($row=mysql_fetch_array($result))
    //列出所有的記錄
    {$filestr.="<".$table.">";
    $fields=mysql_list_fields("embed",$table,$con);
    $j=0;
    //$num_fields=mysql_field_name($fields,$j);
    //echo $num_fields;
    while ($j$num_fields=mysql_field_name($fields,$j);
    $filestr.="<".$num_fields.">";
    $filestr.=$row[$j];
    $filestr.="";
    $j++;}
    $filestr.="";
    }
    $filestr.="";
    echo $filestr;
    //以下是文件操作代碼
    $filename=$table.".xml";
    $fp=fopen("$filename","w");
    fwrite($fp,$filestr);
    fclose($fp);
    Echo "數據表".$table."已經備份成功!";?>

    通過以上文件的操作就可以實現對數據庫中選定的表格進行備份.

    以上主要介紹了通過PHP實現XML備份數據庫的操作方法,其實并不復雜,通過XML,我們可以備份各種各樣的數據庫,當然也可以通過相關的方法將備份的XML文檔恢復到數據庫中,這里就不詳細描述了。

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>