PHP code example of clevis / database-backup

1. Go to this page and download the library: Download clevis/database-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/ */

    

clevis / database-backup example snippets


$mysqli = new mysqli('localhost', 'root', 'password', 'database');
$dumper = new MySQLDump($mysqli);

// store backups to directory './backups' and keep at most 100 backups
$backup = new Clevis\DatabaseBackup\DatabaseBackup($dumper, __DIR__ . '/backups', 100);
$backup->backupDatabase();

$mysqli = $dibiConnection->getDriver()->getResource();

	$dumper->tables['foo'] = $dumper::NONE;
	

	// CREATE TABLE `foo` (...)
	$dumper->tables['foo'] = $dumper::CREATE;

	// DROP TABLE `foo` IF EXISTS + CREATE TABLE `foo` (...)
	$dumper->tables['foo'] = $dumper::CREATE | $dumper::DROP;
	

	$dumper->setCustomDataSelect('foo', 'SELECT * FROM `foo` WHERE `bar` = 1');
	

	$dumper->setUseLock(FALSE);