分享一个php实现MYSQL备份的类库,phpmysql备份类库
正好要研究如何备份数据库,分享一个php实现MYSQL备份的类库
<?php /****** 备份数据库结构 ******/ /****正好要研究如何备份数据库,分享一个php实现MYSQL备份的类库********/ /* 函数名称:table2sql() 函数功能:把表的结构转换成为SQL 函数参数:$table: 要进行提取的表名 返 回 值:返回提取后的结果,SQL集合 函数作者: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].";\n\n"; return $tabledump; } /****** 备份数据库结构和所有数据 ******/ /* 函数名称:data2sql() 函数功能:把表的结构和数据转换成为SQL 函数参数:$table: 要进行提取的表名 返 回 值:返回提取后的结果,SQL集合 函数作者: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].";\n\n"; $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; } ?>
详细说明:http://php.662p.com/thread-560-1-1.html
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article
How to fix KB5055612 fails to install in Windows 10?
4 weeks agoByDDD
Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Roblox: Grow A Garden - Complete Mutation Guide
3 weeks agoByDDD
Nordhold: Fusion System, Explained
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Zend Studio 13.0.1
Powerful PHP integrated development environment

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 English version
Recommended: Win version, supports code prompts!

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
