久久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)文章:
主站蜘蛛池模板: 香港| 简阳市| 泾阳县| 涡阳县| 清远市| 卫辉市| 房产| 阜城县| 定州市| 黄陵县| 建湖县| 西藏| 南安市| 柳江县| 呼和浩特市| 嘉黎县| 镇赉县| 华容县| 新源县| 曲阳县| 松溪县| 淮阳县| 扶风县| 和平区| 镶黄旗| 睢宁县| 铁力市| 肇东市| 丰镇市| 东港市| 搜索| 永济市| 石柱| 石阡县| 井冈山市| 巨鹿县| 康乐县| 临朐县| 故城县| 安丘市| 开远市|