PHP code example of phelium / mysql-backup

1. Go to this page and download the library: Download phelium/mysql-backup library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

phelium / mysql-backup example snippets




use Phelium\Component\MySQLBackup;

$Dump = new MySQLBackup('server name', 'user name', 'password', 'db name', 'mysql port');

$Dump = new MySQLBackup('localhost', 'root', '', 'blog');
$Dump->addTable('posts'); // Add the posts table
$Dump->addTables(array('users', 'comments')); // Add the users and comments tables

$Dump = new MySQLBackup('localhost', 'root', '', 'blog');
$Dump->excludeTables(array(comments')); // Exclude comments table to the backup

$Dump = new MySQLBackup('localhost', 'root', '', 'blog');
$Dump->setFilename('bkp_'.time());

$Dump = new MySQLBackup('localhost', 'root', '', 'blog');
$Dump->setDumpStructure(false); // Not the structure
$Dump->setDumpDatas(false); // Not the datas

$Dump = new MySQLBackup('localhost', 'root', '', 'blog');
$Dump->addCreateDatabaseIfNotExists(false); // Not add the CREATE DATABASE IF NOT EXISTS statment

$Dump = new MySQLBackup('localhost', 'root', '', 'blog');
$Dump->addDropTable(false); // Not add the DROP TABLE IF EXISTS statment

$Dump = new MySQLBackup('localhost', 'root', '', 'blog');
$Dump->addIfNotExists(false); // Not add the IF NOT EXISTS statment

$Dump = new MySQLBackup('localhost', 'root', '', 'blog');
$Dump->setCompress('zip'); // zip | gz | gzip

$Dump = new MySQLBackup('localhost', 'root', '', 'blog');
$Dump->setDelete(true);

$Dump = new MySQLBackup('localhost', 'root', '', 'blog');
$Dump->setDownload(true); // starts downloading

$Dump = new MySQLBackup('localhost', 'root', '', 'blog');
$Dump->dump();


use Phelium\Component\MySQLBackup;

$Dump = new MySQLBackup('localhost', 'root', '', 'blog');
$Dump->addTables(array('posts', 'comments', 'users'));
$Dump->setCompress('zip');
$Dump->setDelete(true);
$Dump->setDownload(true);
$Dump->dump();

// or

$Dump = new MySQLBackup('localhost', 'root', '', 'blog');
$Dump
    ->addTables(array('posts', 'comment', 'users'));
    ->setCompress('zip');
    ->setDelete(true);
    ->setDownload(true);
    ->dump();