All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
C#程序开发中的常用函数汇总_.net资料_编程技术
SQL Server安装挂起错误解决方式_[SQL Server教程]
asp.net2.0服务器控件SiteMapPath的功能
NET精简框架的“无法找到资源程序集”异常释疑_[Asp.Net教程]
Session丢失原因与解决方案小结_php资料_编程技术
JScript中正则表达式用法详解_JavaScript技术_编程技术
将DataGrid或GridView中的数据生成Excel_[Asp.Net教程]
SQL,Server,7.0,入门(五)_mssql学习_编程技术
asp.net2.0内置Request对象的属性
delphi自绘栅格组件(TDrawGrid)使用方法
Reading number is top 10 pictures
The money of more than 100 countries and regions7
Cesarean section, bloody, silently into it!1
Fierce! China's special forces training the devil2
50个至今影响世界的德国发明
Sora aoi possession photo1
某某人向找小三的人宣战了
中国处女图鉴1
2015中美最新武器装备巅峰对决!
Beautiful Japanese beauty(漂亮的日本美女)3
玩手机对身体不好
Download software ranking
matrix1
Tram sex maniac 2 (H) rar bag16
传奇私服架设教程
jdk1.6 for windows
Boxer Classic video1
Boxer vs Yellow5
DreamWeaver8
Boxer vs Yellow4
Boxer vs Yellow1
1400篇各类破解文章
归海一刀 published in(发表于) 2014/2/17 7:34:32 Edit(编辑)
php常用数据库备份类_[PHP教程]

php常用数据库备份类_[PHP教程]

php常用数据库备份类_[PHP教程]
php代码:

/*******************************************************
**文 件 名:DBManagement.php
**描 述:实现数据的导入导出,数据表结构的导入导出
********************************************************/
//
//包含Mysql数据库操作文件
//
require_once("MysqlDB.php");

/*******************************************************
**类 名:MysqlDB
********************************************************/
class DBManagement implements IDBManagement
{
//
//当前数据库中所有的数据表的名字
//
private $TablesName;
//
//默认路径
//
private $DefaultPath;
//
//当前要操作的数据库名
//
private $DatabaseName;
//
//操作数据库的对象
//
private $db;

/*******************************************************
**方 法 名:__construct
**功能描述:创建一个DBManagement的对象
**输入参数:$_DatabaseName-string<要操作的数据库名,如果为空则从配置文件中读取>
** $_DefaultPath-string<存储数据的默认路径,如果为空则从配置文件中读取>
**输出参数:无
**返 回 值:无
********************************************************/
function __construct($_DatabaseName="",$_DefaultPath="")//
{
require("config.inc.php");
if(!$_DatabaseName) {$this->DatabaseName=$dbName;}
else {$this->DatabaseName=$_DatabaseName;}

if(!$_DefaultPath) {$this->DefaultPath=$defaultPath;}
else {$this->DefaultPath=$_DefaultPath;}
$path=realpath($this->DefaultPath);
$this->DefaultPath=str_replace("\\","/",$path);
//$this->db=new DBFactory();
$this->db=new MysqlDB();
}

/*******************************************************
**方 法 名:GetTablesName
**功能描述:获取$this->Database的所有数据表的名字
**输入参数:无
**输出参数:无
**返 回 值:-array <$this->TablesName:$this->Database的所有数据表的名字>
********************************************************/
protected function GetTablesName()
{
$result=$this->db->Query("show table status");
while($Row=$this->db->NextRecord($result))
{
$this->TablesName[]=$Row["Name"];
}
return $this->TablesName;
}

/*******************************************************
**方 法 名:GetDataFileName
**功能描述:获取与$this->Database的所有数据表对应的数据文件的物理文件名
**输入参数:无
**输出参数:无
**返 回 值:-array <$DataFilesName:$与$this->Database的所有数据表对应的数据文件的物理文件名>
********************************************************/
protected function GetDataFileName()
{
$this->GetTablesName();
$count=count($this->GetTablesName());
for ($i=0;$i<$count;$i++)
{
$DataFilesName[]=$this->DefaultPath."/".$this->TablesName[$i].".txt";
//echo $DataFilesName[$i];
}
return $DataFilesName;
}

/*******************************************************
**方 法 名:SaveTableStructure
**功能描述:保存数据表的结构到install.sql文件中,目标路径为$DefaultPath
**输入参数:无
**输出参数:无
**返 回 值:- bool<返回为true表示保存成功;
** 为false表示保存失败>
**作 者:林超旗
**日 期:2007-04-09
**修 改 人:
**日 期:
********************************************************/
protected function SaveTableStructure($text)
{
$fileName=$this->DefaultPath."/Install.sql";
//if(file_exists($fileName))
//{
// unlink($fileName);
//}
//echo $text;
$fp=fopen($fileName,"w+");
fwrite($fp,$text);
}

/*******************************************************
**方 法 名:RestoreTableStructure
**功能描述:备份$this->Database中所有数据表的结构
**输入参数:无
**输出参数:无
**返 回 值:- bool<返回为true表示所有数据表的结构备份成功;
** 为false表示全部或部分数据表的结构备份失败>
**作 者:林超旗
**日 期:2007-04-09
**修 改 人:
**日 期:
********************************************************/
protected function BackupTableStructure()
{
$i=0;
$sqlText="";

$this->GetTablesName();
$count=count($this->TablesName);
//
//取出所有数据表的结构
//
while($i<$count)
{
$tableName=$this->TablesName[$i];
$result=$this->db->Query("show create table $tableName");
$this->db->NextRecord($result);
//
//取出成生表的SQL语句
//
$sqlText.="DROP TABLE IF EXISTS `".$tableName."`; ";//`
$sqlText.=$this->db->GetField(1)."; ";
$i++;
}
$sqlText=str_replace("\r","",$sqlText);
$sqlText=str_replace("\n","",$sqlText);
//$sqlText=str_replace("’","`",$sqlText);
$this->SaveTableStructure($sqlText);
}



添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.