Skip to content

Commit

Permalink
Add options for export and import (#6)
Browse files Browse the repository at this point in the history
* Update MysqlPlugin.php

* Update MysqlPlugin.php

* Update MysqlPlugin.php
  • Loading branch information
wachterjohannes authored Jul 27, 2020
1 parent d4cfb2b commit 143afe3
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/MysqlPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ public function configureOptionsResolver(OptionsResolver $optionsResolver)
$optionsResolver->setRequired(['username', 'database'])
->setDefault('password', null)
->setDefault('host', null)
->setDefault('port', null);
->setDefault('port', null)
->setDefault('exportOptions', null)
->setDefault('importOptions', null);
}

/**
Expand Down Expand Up @@ -106,13 +108,15 @@ private function getExportCommand(array $parameter, $file, $hidePassword = false
$database = $parameter['database'];
$host = $parameter['host'];
$port = $parameter['port'];
$options = $parameter['exportOptions'];

return sprintf(
'mysqldump -u%s%s%s%s %s > %s',
'mysqldump -u%s%s%s%s%s %s > %s',
$username,
isset($password) ? (' -p' . ($hidePassword ? '***' : "'" . addcslashes($password, "'") . "'")) : '',
isset($host) ? (' -h ' . $host) : '',
isset($port) ? (' -P ' . $port) : '',
isset($options) ? (' ' . $options) : '',
$database,
$file
);
Expand All @@ -134,13 +138,15 @@ private function getImportCommand(array $parameter, $file, $hidePassword = false
$database = $parameter['database'];
$host = $parameter['host'];
$port = $parameter['port'];
$options = $parameter['importOptions'];

return sprintf(
'mysql -u%s%s%s%s %s < %s',
'mysql -u%s%s%s%s%s %s < %s',
$username,
isset($password) ? (' -p' . ($hidePassword ? '***' : $password)) : '',
isset($host) ? (' -h ' . $host) : '',
isset($port) ? (' -P ' . $port) : '',
isset($options) ? (' ' . $options) : '',
$database,
$file
);
Expand Down

0 comments on commit 143afe3

Please sign in to comment.