Skip to content

Commit

Permalink
Hotfix for creating dsn string
Browse files Browse the repository at this point in the history
  • Loading branch information
back-2-95 committed Aug 24, 2022
1 parent 6623647 commit a23a142
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Command/DumpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,24 +276,24 @@ protected function getDefaults($extraFile): array
*/
protected function getDsn(array $dumpSettings): string
{
$dsn = sprintf('%s:', $dumpSettings['db-type']);
$elements = [];

if ($dumpSettings['host']) {
$dsn .= sprintf(';host=%s', $dumpSettings['host']);
$elements[] = sprintf('host=%s', $dumpSettings['host']);

if ($dumpSettings['port']) {
$dsn .= sprintf(';port=%s', $dumpSettings['port']);
$elements[] = sprintf('port=%s', $dumpSettings['port']);
}
}
else if ($dumpSettings['socket']) {
$dsn .= sprintf(";unix_socket=%s", $dumpSettings['socket']);
$elements[] = sprintf('unix_socket=%s', $dumpSettings['socket']);
}

if ($dumpSettings['db-name']) {
$dsn .= sprintf(';dbname=%s', $dumpSettings['db-name']);
$elements[] = sprintf('dbname=%s', $dumpSettings['db-name']);
}

return $dsn;
return sprintf('%s:%s', $dumpSettings['db-type'], join(';', $elements));
}

protected function getOptOptions($switch): array
Expand Down

0 comments on commit a23a142

Please sign in to comment.