| Recommend this page to a friend! | 
| Info | Documentation | Reputation | Support forum | Blog | Links | 
| Ratings | Unique User Downloads | Download Rankings | ||||
| Not yet rated by the users | Total: 208 | All time:  8,394 This week: 56 | ||||
| Version | License | PHP version | Categories | |||
| mysqldump-php 1.0.0 | Custom (specified... | 5 | PHP 5, Databases | 
| Description | Author  | |
This package can dump MySQL database contents like mysqldump tool.  | 
Mysql Dumper is the only library that supports: * Output binary blobs as hex. * Resolves view dependencies (using Stand-In tables). * Dumps stored procedures. * Dumps events. * Does extended-insert and/or complete-insert. * Supports virtual columns from MySQL 5.7.
Using Composer:
$ composer require niko9911/mysqldump-php:1.*
Or via json file:
"require": {
        "niko9911/mysqldump-php":"1.*"
}
Using Curl to always download and decompress the latest release:
$ curl --silent --location https://api.github.com/repos/niko9911/mysqldump-php/releases | grep -i tarball_url | head -n 1 | cut -d '"' -f 4 | xargs curl --location --silent | tar xvz
With Autoloader/Composer:
<?php
use Niko9911\MysqlDump\Dump;
try {
    $dump = new Dump('mysql:host=localhost;dbname=testdb', 'username', 'password');
    $dump->start('storage/work/dump.sql');
} catch (\Exception $e) {
    echo 'Error: ' . $e->getMessage();
}
Refer to the wiki for some examples and a comparision between mysqldump and mysqldump-php dumps.
/
 * Constructor of Mysqldump. Note that in the case of an SQLite database
 * connection, the filename must be in the $db parameter.
 *
 * @param string $dsn        PDO DSN connection string
 * @param string $user       SQL account username
 * @param string $pass       SQL account password
 * @param array  $dumpSettings SQL database settings
 * @param array  $pdoSettings  PDO configured attributes
 */
public function __construct(
    $dsn = '',
    $user = '',
    $pass = '',
    $dumpSettings = array(),
    $pdoSettings = array()
)
$dumpSettingsDefault = array(
    'include-tables' => array(),
    'exclude-tables' => array(),
    'compress' => Mysqldump::NONE,
    'init_commands' => array(),
    'no-data' => array(),
    'reset-auto-increment' => false,
    'add-drop-database' => false,
    'add-drop-table' => false,
    'add-drop-trigger' => true,
    'add-locks' => true,
    'complete-insert' => false,
    'databases' => false,
    'default-character-set' => Mysqldump::UTF8,
    'disable-keys' => true,
    'extended-insert' => true,
    'events' => false,
    'hex-blob' => true, /faster than escaped content/
    'net_buffer_length' => self::MAXLINESIZE,
    'no-autocommit' => true,
    'no-create-info' => false,
    'lock-tables' => true,
    'routines' => false,
    'single-transaction' => true,
    'skip-triggers' => false,
    'skip-tz-utc' => false,
    'skip-comments' => false,
    'skip-dump-date' => false,
    'skip-definer' => false,
    'where' => '',
    /deprecated/
    'disable-foreign-keys-check' => true
);
$pdoSettingsDefaults = array(
    PDO::ATTR_PERSISTENT => true,
    PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
    PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => false
);
// missing settings in constructor will be replaced by default options
$this->_pdoSettings = self::array_replace_recursive($pdoSettingsDefault, $pdoSettings);
$this->_dumpSettings = self::array_replace_recursive($dumpSettingsDefault, $dumpSettings);
The following options are now enabled by default, and there is no way to disable them since they should always be used.
To dump a database, you need the following privileges :
Use SHOW GRANTS FOR user@host; to know what privileges user has. See the following link for more information:
Which are the minimum privileges required to get a backup of a MySQL database schema?
GitLab CI & Automatic Deployment to Composer
Format all code to PHP-FIG standards. http://www.php-fig.org/
This project is open-sourced software licensed under the GPL license For commercial licenses, please contact niko-at-ironlions-dot-fi.
After more than 8 years, there is barely anything left from the original source code, but:
Originally based on James Elliott's script from 2009. http://code.google.com/p/db-mysqldump/
Adapted and extended by Michael J. Calkins. https://github.com/clouddueling
Rewrite based on from Diego Torres. https://github.com/ifsnop
Currently maintained, developed and improved by Niko Granö. https://github.com/niko9911
| File | Role | Description | ||
|---|---|---|---|---|
| Data | Auxiliary data | |||
| Data | Auxiliary data | |||
| Data | Auxiliary data | |||
| Lic. | License text | |||
| Doc. | Read me | |||
| / | src | 
| File | Role | Description | ||
|---|---|---|---|---|
|    | 
Class | Class source | ||
| / | src | / | Compress | 
| File | Role | Description | 
|---|---|---|
|    | 
Class | Class source | 
|    | 
Class | Class source | 
|    | 
Class | Class source | 
|    | 
Class | Class source | 
|    | 
Class | Class source | 
| / | src | / | TypeAdapter | 
| File | Role | Description | 
|---|---|---|
|    | 
Class | Class source | 
|    | 
Class | Class source | 
|    | 
Class | Class source | 
|    | 
Class | Class source | 
|    | 
Class | Class source | 
| The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. | 
| Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
| 100% | 
  | 
  | 
| Applications that use this package | 
 If you know an application of this package, send a message to the author to add a link here.