淺析php常用數(shù)據(jù)庫(kù)備份類_PHP教程
教程Tag:暫無(wú)Tag,歡迎添加,賺取U幣!
推薦:淺析php實(shí)現(xiàn)大文件上傳源代碼一個(gè)比較 經(jīng)典的php大文件上傳源代碼,可成功運(yùn)行. functionfunction_upload($name,$newname=,$dir=upload) { global$_FILES,$ext; $return=; $time=time(); $upload=trim($_FILES[$name][’tmp_name’]); $upload_name=trim($_FILES[$name][’name’])
| php代碼: <?php /******************************************************* **文 件 名:DBManagement.php **描 述:實(shí)現(xiàn)數(shù)據(jù)的導(dǎo)入導(dǎo)出,數(shù)據(jù)表結(jié)構(gòu)的導(dǎo)入導(dǎo)出 ********************************************************/ // //包含Mysql數(shù)據(jù)庫(kù)操作文件 // require_once("MysqlDB.php"); /******************************************************* **類 名:MysqlDB ********************************************************/ class DBManagement implements IDBManagement { // //當(dāng)前數(shù)據(jù)庫(kù)中所有的數(shù)據(jù)表的名字 // private $TablesName; // //默認(rèn)路徑 // private $DefaultPath; // //當(dāng)前要操作的數(shù)據(jù)庫(kù)名 // private $DatabaseName; // //操作數(shù)據(jù)庫(kù)的對(duì)象 // private $db; /******************************************************* **方 法 名:__construct **功能描述:創(chuàng)建一個(gè)DBManagement的對(duì)象 **輸入?yún)?shù):$_DatabaseName-string<要操作的數(shù)據(jù)庫(kù)名,如果為空則從配置文件中讀取> ** $_DefaultPath-string<存儲(chǔ)數(shù)據(jù)的默認(rèn)路徑,如果為空則從配置文件中讀取> **輸出參數(shù):無(wú) **返 回 值:無(wú) ********************************************************/ 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的所有數(shù)據(jù)表的名字 **輸入?yún)?shù):無(wú) **輸出參數(shù):無(wú) **返 回 值:-array <$this->TablesName:$this->Database的所有數(shù)據(jù)表的名字> ********************************************************/ 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的所有數(shù)據(jù)表對(duì)應(yīng)的數(shù)據(jù)文件的物理文件名 **輸入?yún)?shù):無(wú) **輸出參數(shù):無(wú) **返 回 值:-array <$DataFilesName:$與$this->Database的所有數(shù)據(jù)表對(duì)應(yīng)的數(shù)據(jù)文件的物理文件名> ********************************************************/ 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 **功能描述:保存數(shù)據(jù)表的結(jié)構(gòu)到install.sql文件中,目標(biāo)路徑為$DefaultPath **輸入?yún)?shù):無(wú) **輸出參數(shù):無(wú) **返 回 值:- 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中所有數(shù)據(jù)表的結(jié)構(gòu) **輸入?yún)?shù):無(wú) **輸出參數(shù):無(wú) **返 回 值:- bool<返回為true表示所有數(shù)據(jù)表的結(jié)構(gòu)備份成功; ** 為false表示全部或部分?jǐn)?shù)據(jù)表的結(jié)構(gòu)備份失敗> **作 者:林超旗 **日 期:2007-04-09 **修 改 人: **日 期: ********************************************************/ protected function BackupTableStructure() { $i=0; $sqlText=""; $this->GetTablesName(); $count=count($this->TablesName); // //取出所有數(shù)據(jù)表的結(jié)構(gòu) // while($i<$count) { $tableName=$this->TablesName[$i]; $result=$this->db->Query("show create table $tableName"); $this->db->NextRecord($result); // //取出成生表的SQL語(yǔ)句 // $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); } |
分享:解析PHP如何輸出簡(jiǎn)單動(dòng)態(tài)WAP頁(yè)面WAP(無(wú)線通訊協(xié)議)是在數(shù)字移動(dòng)電話、個(gè)人手持設(shè)備(PDA等)及計(jì)算機(jī)之間進(jìn)行通訊的開放性全球標(biāo)準(zhǔn)。WAP應(yīng)用結(jié)構(gòu)非常類似于Internet,一個(gè)典型的WAP應(yīng)用請(qǐng)求是這樣的:首先,具有WAP用戶代理功能的移動(dòng)終端(WAP手機(jī)等)通過內(nèi)部運(yùn)行的微瀏覽器(MicroBrowser
相關(guān)PHP教程:
- PHPNOW安裝Memcached擴(kuò)展方法詳解
- php記錄頁(yè)面代碼執(zhí)行時(shí)間
- PHP中獎(jiǎng)概率的抽獎(jiǎng)算法程序代碼
- apache設(shè)置靜態(tài)文件緩存方法介紹
- php對(duì)圖像的各種處理函數(shù)代碼小結(jié)
- PHP 關(guān)于訪問控制的和運(yùn)算符優(yōu)先級(jí)介紹
- 關(guān)于PHP語(yǔ)言構(gòu)造器介紹
- php/js獲取客戶端mac地址的實(shí)現(xiàn)代碼
- php5.5新數(shù)組函數(shù)array_column使用
- PHP preg_match的匹配多國(guó)語(yǔ)言的技巧
- php 中序列化和json使用介紹
- php采集文章中的圖片獲取替換到本地
- 相關(guān)鏈接:
- 教程說(shuō)明:
PHP教程-淺析php常用數(shù)據(jù)庫(kù)備份類
。