devphp-pmro/backupsql

以简单的方式备份MySQL中的表格

1.0.2 2020-10-07 01:52 UTC

This package is auto-updated.

Last update: 2024-09-04 20:37:17 UTC


README

要安装库,请运行以下命令

composer require devphp-pmro/backupsql

要使用库,只需调用composer自动加载,调用类并调用方法

<? php

open the bd.php file in the source folder and enter the credentials for connecting to the database

//define the connection settings to the database for backup

define("CONFIG",["host" => "host,
                "user" => "user",
                "password" => "password",
                "data_base" => "data_base",
                "port"=> "port"]);

default port 3306

// compress or download in method contruct is optional

require __DIR__. '/vendor-dir/autoload.php';

use Source\BackupSql;

$bk = new BackupSql($fileName, true, "zip",true); // new instance

$fileName = 'backup'.date('Y-m-d'); //the file name in the building method is mandatory

$bk->createSelectTables(["table_name","table_name1"]); //insert the table numbers to be backed up

$bk = new BackupSql($fileName, true, "zip",true); // new instance

$bk->createAllTables(); //all tables

// compress = zip | gz | gzip (optional)

// download true or false

if deleteFile is false the file will be saved in the folder where the class was instantiated, so if you want the file not to be automatically saved, put deleteFile true and download as true

开发者

许可协议

MIT