<?php class DBManage { var $db; // 数据库连接 var $database; // 所用数据库 var $sqldir; // 数据库备份文件夹 var $record; // 换行符 private $ds = "n"; // 存储SQL的变量 public $sqlContent = ""; // 每条sql语句的结尾符 public $sqlEnd = ";"; /** * 初始化 * * @param string $host * @param string $username * @param string $password * @param string $thisatabase * @param string $charset */
Description: The volume file ends with _v1.sql
Function: Implement mysql database volume backup, select tables for backup, and implement single sql file and volume sql import
Usage:
1. Database backup (export)-------------------------------- ----------------------------
//They are the host, user name, password, and database name respectively. , database encoding
$db = new DBManage ('localhost', 'root', 'root', 'test', 'utf8' );
//Parameter: which table to back up ( Optional), backup directory (optional, default is backup), volume size (optional, default is 2000, which is 2M)
$db->backup ();
* ------2. Database recovery (import)--------------------------------------------- -----------------------
//They are the host, user name, password, database name, and database encoding
$db = new DBManage ('localhost', 'root', 'root', 'test', 'utf8' );
//Parameter: sql file
All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn
Related Article
13 Jul 2016
PHP implements MySQL database backup and restore class instances, mysql database backup. PHP implements MySQL database backup and restore class examples, mysql database backup This article describes the PHP implementation of MySQL database backup and restore classes. Share it with everyone for your reference. Specific analysis such as
13 Jul 2016
PHP database backup and restore class sharing. Copy the code The code is as follows: ?php /** * Database backup and restore class * @author xialeistudioadmin@xialeistudio.net * Class DatabaseTool */ class DatabaseTool { private $handler; private $
29 Jul 2023
PHP and PDO: How to perform database backup and restore operations When developing web applications, database backup and restore are very important tasks. As a popular server-side scripting language, PHP provides a wealth of libraries and extensions, among which PDO (PHP Data Objects) is a powerful database access abstraction layer. This article will introduce how to use PHP and PDO to perform database backup and restore operations. Step 1: Connect to the database Before actual operation, we need to establish a connection to the database. Use PDO pair
23 Jun 2017
In view of some of its own characteristics (lock table, insert script or text is essentially backed up, differential backup is not supported), mysqldump backup is not suitable for situations that require high real-time performance. Xtrabackup can solve some of the above problems of mysqldump. There will also be more applications in the production environment. This article briefly tests Xtrabackup's backup and restore operation of the MySQL database. In line with the principle of rolling out the functions first and then going into details, I roughly implemented a backup and restore without going into details.
Hot Tools
PHP library for dependency injection containers
PHP library for dependency injection containers
A collection of 50 excellent classic PHP algorithms
Classic PHP algorithm, learn excellent ideas and expand your thinking
Small PHP library for optimizing images
Small PHP library for optimizing images