Skip to content

Commit

Permalink
testing mysqldump-php under hhvm in travis-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
ifsnop committed Feb 6, 2018
2 parents cd2666b + eb2a10a commit 3e37ea8
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 69 deletions.
134 changes: 66 additions & 68 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ $ composer require ifsnop/mysqldump-php:2.*

Or via json file:

````
```
"require": {
"ifsnop/mysqldump-php":"2.*"
}
````
```

Using [Curl](http://curl.haxx.se) to always download and decompress the latest release:

Expand All @@ -65,7 +65,7 @@ $ curl --silent --location https://api.github.com/repos/ifsnop/mysqldump-php/rel

With [Autoloader](http://www.php-fig.org/psr/psr-4/)/[Composer](http://getcomposer.org):

```
```php
<?php

use Ifsnop\Mysqldump as IMysqldump;
Expand All @@ -76,85 +76,83 @@ try {
} catch (\Exception $e) {
echo 'mysqldump-php error: ' . $e->getMessage();
}
?>
```

Plain old PHP:

```
```php
<?php

include_once(dirname(__FILE__) . '/mysqldump-php-2.0.0/src/Ifsnop/Mysqldump/Mysqldump.php');
$dump = new Ifsnop\Mysqldump\Mysqldump('mysql:host=localhost;dbname=testdb', 'username', 'password');
$dump->start('storage/work/dump.sql');
?>
```

Refer to the [wiki](https://github.com/ifsnop/mysqldump-php/wiki/full-example) for some examples and a comparision between mysqldump and mysqldump-php dumps.

## Constructor and default parameters
/**
* 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,
'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);
```php
/**
* 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,
'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);
```

## Dump Settings

Expand Down
9 changes: 9 additions & 0 deletions tests/test.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@
'where' => ''
);

print "starting mysql-php_test001.sql" . PHP_EOL;
$dump = new IMysqldump\Mysqldump(
"mysql:host=localhost;dbname=test001",
"travis",
"",
$dumpSettings);
$dump->start("mysqldump-php_test001.sql");

print "starting mysql-php_test002.sql" . PHP_EOL;
$dumpSettings['default-character-set'] = IMysqldump\Mysqldump::UTF8MB4;
$dumpSettings['complete-insert'] = true;
$dump = new IMysqldump\Mysqldump(
Expand All @@ -47,6 +49,7 @@
$dumpSettings);
$dump->start("mysqldump-php_test002.sql");

print "starting mysql-php_test005.sql" . PHP_EOL;
$dumpSettings['complete-insert'] = false;
$dump = new IMysqldump\Mysqldump(
"mysql:unix_socket=/var/run/mysqld/mysqld.sock;dbname=test005",
Expand All @@ -55,41 +58,47 @@
$dumpSettings);
$dump->start("mysqldump-php_test005.sql");

print "starting mysql-php_test006.sql" . PHP_EOL;
$dump = new IMysqldump\Mysqldump(
"mysql:unix_socket=/var/run/mysqld/mysqld.sock;dbname=test006a",
"travis",
"",
array("no-data" => true, "add-drop-table" => true));
$dump->start("mysqldump-php_test006.sql");

print "starting mysql-php_test008.sql" . PHP_EOL;
$dump = new IMysqldump\Mysqldump(
"mysql:unix_socket=/var/run/mysqld/mysqld.sock;dbname=test008",
"travis",
"",
array("no-data" => true, "add-drop-table" => true));
$dump->start("mysqldump-php_test008.sql");

print "starting mysql-php_test009.sql" . PHP_EOL;
$dump = new IMysqldump\Mysqldump(
"mysql:unix_socket=/var/run/mysqld/mysqld.sock;dbname=test009",
"travis",
"",
array("no-data" => true, "add-drop-table" => true, "reset-auto-increment" => true, "add-drop-database" => true));
$dump->start("mysqldump-php_test009.sql");

print "starting mysql-php_test010.sql" . PHP_EOL;
$dump = new IMysqldump\Mysqldump(
"mysql:unix_socket=/var/run/mysqld/mysqld.sock;dbname=test010",
"travis",
"",
array("events" => true));
$dump->start("mysqldump-php_test010.sql");

print "starting mysql-php_test011a.sql" . PHP_EOL;
$dump = new IMysqldump\Mysqldump(
"mysql:unix_socket=/var/run/mysqld/mysqld.sock;dbname=test011",
"travis",
"",
array('complete-insert' => false));
$dump->start("mysqldump-php_test011a.sql");

print "starting mysql-php_test011b.sql" . PHP_EOL;
$dump = new IMysqldump\Mysqldump(
"mysql:unix_socket=/var/run/mysqld/mysqld.sock;dbname=test011",
"travis",
Expand Down
2 changes: 1 addition & 1 deletion tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ mysqldump -utravis test005 \
> mysqldump_test005.sql
ret[((index++))]=$?

php test.php || { echo "ERROR running test.php" && exit; }
php test.php || { echo "ERROR running test.php" && exit -1; }
ret[((index++))]=$?

mysql -utravis test001 < mysqldump-php_test001.sql
Expand Down

0 comments on commit 3e37ea8

Please sign in to comment.