首頁 >後端開發 >php教程 >mysql php数据打包备份程序_PHP教程

mysql php数据打包备份程序_PHP教程

WBOY
WBOY原創
2016-07-20 11:06:371100瀏覽

mysql php数据打包备份程序
 if (!$dbname) {
  $errmsg = 'Please input dbname';
 } else {
  dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
  if (!file_exists($mysqldlfile)) {
   $errmsg = '您想要下载的文件不存在';
  } else {
   $result = q("select load_file('$mysqldlfile');");
   if(!$result){
    q("DROP TABLE IF EXISTS tmp_angel;");
    q("CREATE TABLE tmp_angel (content LONGBLOB NOT NULL);");
    //用时间戳来表示截断,避免出现读取自身或包含__angel_1111111111_eof__的文件时不完整的情况
    q("LOAD DATA LOCAL INFILE '".addslashes($mysqldlfile)."' INTO TABLE tmp_angel FIELDS TERMINATED BY '__angel_{$timestamp}_eof__' ESCAPED BY '' LINES TERMINATED BY '__angel_{$timestamp}_eof__';");
    $result = q("select content from tmp_angel");
    q("DROP TABLE tmp_angel");
   }
   $row = @mysql_fetch_array($result);
   if (!$row) {
    $errmsg = 'Load file failed '.mysql_error();
   } else {
    $fileinfo = pathinfo($mysqldlfile);
    header('Content-type: application/x-'.$fileinfo['extension']);
    header('Content-Disposition: attachment; filename='.$fileinfo['basename']);
    header("Accept-Length: ".strlen($row[0]));
    echo $row[0];
    exit;
   }
  }
 }


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/445024.htmlTechArticlemysql php数据打包备份程序 if (!$dbname) { $errmsg = 'Please input dbname'; } else { dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport); if (!file_exists($mysqldl...
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn