PHP code example of y0lk / sqldumper
1. Go to this page and download the library: Download y0lk/sqldumper 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/ */
y0lk / sqldumper example snippets
use Y0lk\SQLDumper\SQLDumper;
//Init the dumper with your DB info
$dumper = new SQLDumper('localhost', 'dbname', 'root', '');
//Set all tables to dump without data and without DROP statement
$dumper->allTables()
->withData(false)
->withDrop(false);
//Set table1 to dump with data
$dumper->table('table1')
->withData(true);
//Set table2 and table3 to dump without structure (data only), and table3 with where condition
$dumper->listTables([
'table2',
'table3'
])
->withStructure(false)
->table('table3')
->where('id=2 OR foo="bar"');
//This will group DROP statements and put them at the beginning of the dump
$dumper->groupDrops(true);
//This will group INSERT statements and put them at the end of the dump
$dumper->groupInserts(true);
$dumper->save('dump.sql');