baneeishaque/mysql-db-exporter

Export MySQL Database

dev-master 2021-02-28 09:17 UTC

This package is auto-updated.

Last update: 2021-02-28 09:17:24 UTC


README

Initialize

include('db_backup_library.php');
$dbbackup = new db_backup;

Just Use include() or require() to the 'db_backup_library.php' File And create an object of 'db_backup' class

Methods

connect()

This is an Optional Method If your project connected with Server and database already then you don't need to use this Method, Other wise you can use this method to connect with MySQL Server and Database

Example

include('db_backup_library.php');
$dbbackup = new db_backup;
$dbbackup->connect("Server Name", Username, passwrd, Database)

backup()

This is a Mandatory Method After connecting with Server and Database you must call this method other wise other method cannot work.

Example

include('db_backup_library.php');
$dbbackup = new db_backup;
$dbbackup->connect("ServerName","Username","passwrd","Database");
$dbbackup->backup();

tables()

If you need to show the name of all tables in database just call this method it will return an array with the name of all tables in the database.

Example

include('db_backup_library.php');
$dbbackup = new db_backup;
$dbbackup->connect("ServerName","Username","passwrd","Database");
$dbbackup->backup();
print_r($dbbackup->tables());

download()

If you want to download The database you can use this method. After run this method you will see a Download Popup menu of database SQL file.

Example

<a href="tests/download.php">Download</a>

'download.php' Contain Only This code:

include('db_backup_library.php');
$dbbackup = new db_backup;
$dbbackup->connect("ServerName","Username","passwrd","Database");
$dbbackup->backup();
$dbbackup->download();

Note: This is the better way to keep the download code into a single page.

save()

If you want to save the backup file into a server directory you can use this method

Parameters

It has 2 Parameters

1st parameter is Target path (where you want to save the file) It is Mandatory If you want to kip it blank you can just use save("")

2nd Parameter is (Optional) name of The file Default is 'backup_yyy-mm-dd.sql'

Example

include('db_backup_library.php');
$dbbackup = new db_backup;
$dbbackup->connect("ServerName","Username","passwrd","Database");
$dbbackup->backup();
$dbbackup->save("file/","backup"));

db_import()

To Import the SQL File into your Database you can use this method just call the method with the source path of sql file as parameter Then it will import your database

Parameters

It has 1 Parameters

The parameter is source path of sql file.

Example

include('db_backup_library.php');
$dbbackup = new db_backup;
$dbbackup->connect("ServerName","Username","passwrd","Database");
$dbbackup->backup();
$dbbackup->db_import("sample/inventory.sql"));

If you have any question about this, just knock me on facebook or email

Fb: fb/emarufhasan Gmail: emarufhasan@gmail.com

See the Video Tutorial: https://www.youtube.com/watch?v=QUS8cYoCk7Q