久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

php 備份數(shù)據(jù)庫(kù)類

瀏覽:2日期:2022-09-12 16:42:03

<?php/****** 備份數(shù)據(jù)庫(kù)結(jié)構(gòu) ******//****正好要研究如何備份數(shù)據(jù)庫(kù),分享一個(gè)php實(shí)現(xiàn)MYSQL備份的類庫(kù)********/ /* 函數(shù)名稱:table2sql() 函數(shù)功能:把表的結(jié)構(gòu)轉(zhuǎn)換成為SQL 函數(shù)參數(shù):$table: 要進(jìn)行提取的表名 返 回 值:返回提取后的結(jié)果,SQL集合 函數(shù)作者:heiyeluren */ function table2sql($table) { global $db; $tabledump = 'DROP TABLE IF EXISTS $table;n'; $createtable = $db->query('SHOW CREATE TABLE $table'); $create = $db->fetch_row($createtable); $tabledump .= $create[1].';nn'; return $tabledump; } /****** 備份數(shù)據(jù)庫(kù)結(jié)構(gòu)和所有數(shù)據(jù) ******/ /* 函數(shù)名稱:data2sql() 函數(shù)功能:把表的結(jié)構(gòu)和數(shù)據(jù)轉(zhuǎn)換成為SQL 函數(shù)參數(shù):$table: 要進(jìn)行提取的表名 返 回 值:返回提取后的結(jié)果,SQL集合 函數(shù)作者:heiyeluren */ function data2sql($table) { global $db; $tabledump = 'DROP TABLE IF EXISTS $table;n'; $createtable = $db->query('SHOW CREATE TABLE $table'); $create = $db->fetch_row($createtable); $tabledump .= $create[1].';nn'; $rows = $db->query('SELECT * FROM $table'); $numfields = $db->num_fields($rows); $numrows = $db->num_rows($rows); while ($row = $db->fetch_row($rows)) { $comma = ''; $tabledump .= 'INSERT INTO $table VALUES('; for($i = 0; $i < $numfields; $i++) { $tabledump .= $comma.'’'.mysql_escape_string($row[$i]).'’'; $comma = ','; } $tabledump .= ');n'; } $tabledump .= 'n'; return $tabledump; }?>

標(biāo)簽: PHP
相關(guān)文章:
主站蜘蛛池模板: 京山县| 神农架林区| 张家口市| 中牟县| 安仁县| 定日县| 乃东县| 马尔康县| 宁海县| 苍南县| 芜湖县| 临汾市| 莱西市| 哈密市| 富阳市| 微山县| 兰考县| 休宁县| 新野县| 乌兰浩特市| 永泰县| 安康市| 临湘市| 奉化市| 勐海县| 翁源县| 博客| 富锦市| 察隅县| 织金县| 沙田区| 阿坝| 新巴尔虎左旗| 清丰县| 浙江省| 雅江县| 仁布县| 当涂县| 唐河县| 五家渠市| 洪江市|