Skip to content
CarlosBor edited this page Aug 17, 2023 · 8 revisions

Complete example using autoloader classes.

error_reporting(E_ALL);

require_once __DIR__ . '/vendor/autoload.php';
include_once(dirname(__FILE__) . '/vendor/mysqldump-php/src/Ifsnop/main.inc.php');

use Ifsnop\Mysqldump as IMysqldump;

$date = date('Ymd');
$dumpSettings = array(
    'compress' => IMysqldump\Mysqldump::NONE,
    'no-data' => false,
    'add-drop-table' => true,
    'single-transaction' => true,
    'lock-tables' => true,
    'add-locks' => true,
    'extended-insert' => true,
    'disable-foreign-keys-check' => true,
    'skip-triggers' => false,
    'add-drop-trigger' => true,
    'databases' => true,
    'add-drop-database' => true,
    'hex-blob' => true
    );

$dump = new IMysqldump\Mysqldump("mysql:host=localhost;dbname=testdb", "user", "pass", $dumpSettings);
$dump->start("backup${date}.sql");
Clone this wiki locally