2017 © Pedro Peláez
 

library sqldumper

SQL dump utility

image

y0lk/sqldumper

SQL dump utility

  • Friday, October 27, 2017
  • by Y0lk
  • Repository
  • 2 Watchers
  • 1 Stars
  • 375 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 1 % Grown

The README.md

SQLDumper

Latest Stable Version Build Status Code Coverage Scrutinizer Code Quality License Total Downloads, (*1)

SQLDumper is a small library designed to easily create customized SQL dumps., (*2)

Installation

Via Composer, (*3)

$ composer require y0lk/sqldumper

Usage

The concept is that you can select tables and set certain "dump parameters" for each table, made so you can chain a bunch of calls to quickly create a customized dump., (*4)

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');

Dumper options

groupDrops(bool $group)

When set to TRUE, this will group DROP statements and put them at the beginning of the dump, (*5)

groupInserts(bool $group)

When set to TRUE, this will group INSERT statements and put them at the end of the dump, (*6)

Table selection

There are 3 basic methods to select tables. When a table or a list of tables are selected, they are returned as TableDumper objects on which you can set options for the dump., (*7)

allTables()

Selects all the tables in the DB, (*8)

table(string|Table $table)

Select by table's name (string) or a Table object, (*9)

listTables(array $listTables)

Select by a list of table names (string) or Table object, (*10)

Table options

This is the list of methods available on each each TableDumper, (*11)

withStructure(bool $withStructure)

Whether to dump the table CREATE structure, (*12)

withData(bool $withData)

Whether to dump table data (INSERT statement), (*13)

withDrop(bool $withDrop)

Wheter to include the DROP statement (before CREATE), (*14)

where(string $where_string)

WHERE query string as regular SQL, (*15)

Output

dump(resource $stream)

This the main dump function, outputs the dump to a stream., (*16)

save(string $filename)

Saves the dump to a file, (*17)

License

The MIT License (MIT). Please see License File for more information., (*18)

The Versions

27/10 2017

dev-master

9999999-dev

SQL dump utility

  Sources   Download

MIT

The Requires

  • ext-pdo *
  • ext-pdo_mysql *
  • php >=5.5.0

 

The Development Requires

sql mysql dump mysql-dump

27/10 2017

0.1.2

0.1.2.0

SQL dump utility

  Sources   Download

MIT

The Requires

  • ext-pdo *
  • ext-pdo_mysql *
  • php >=5.5.0

 

The Development Requires

sql mysql dump mysql-dump

04/12 2016

0.1.1

0.1.1.0

SQL dump utility

  Sources   Download

MIT

The Requires

  • ext-pdo *
  • ext-pdo_mysql *
  • php >=5.4.0

 

The Development Requires

sql mysql dump mysql-dump

18/11 2016

0.1

0.1.0.0

SQL dump utility

  Sources   Download

MIT

The Requires

  • ext-pdo *
  • ext-pdo_mysql *
  • php >=5.4.0

 

The Development Requires

sql mysql dump mysql-dump