search
HomePHP LibrariesOther librariesMySQL database backup and restore PHP class
MySQL database backup and restore PHP class
<?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


Disclaimer

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

PHP implements MySQL database backup and restore class examples, mysql database backup_PHP tutorialPHP implements MySQL database backup and restore class examples, mysql database backup_PHP tutorial

13Jul2016

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

PHP database backup and restore class sharing_PHP tutorialPHP database backup and restore class sharing_PHP tutorial

13Jul2016

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 $

Java backup and restore Mysql databaseJava backup and restore Mysql database

10Nov2016

Java backup and restore Mysql database

xtrabackup backup and restore MySQL databasextrabackup backup and restore MySQL database

23Jun2017

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.

PHP and PDO: How to perform database backup and restore operationsPHP and PDO: How to perform database backup and restore operations

29Jul2023

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

php database backup and restorephp database backup and restore

11Jul2016

php database backup and restore,

See all articles