Skip to content

Commit

Permalink
Fix ConnectionConfig key map
Browse files Browse the repository at this point in the history
The key map was not being used prior.
  • Loading branch information
trowski committed Oct 30, 2019
1 parent 931f008 commit 361d93d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/ConnectionConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ final class ConnectionConfig extends SqlConnectionConfig
const BIN_CHARSET = 45; // utf8mb4_general_ci

const KEY_MAP = [
'hostname' => 'host',
'username' => 'user',
'password' => 'pass',
'pass' => 'password',
'database' => 'db',
'dbname' => 'db',
'compress' => 'useCompression',
'charset' => 'charset',
'compress' => 'compression',
'useCompression' => 'compression',
'cs' => 'charset',
'localInfile' => 'local-infile',
];

const DEFAULT_CHARSET = "utf8mb4";
Expand All @@ -39,7 +42,7 @@ final class ConnectionConfig extends SqlConnectionConfig

public static function fromString(string $connectionString, ClientTlsContext $tlsContext = null): self
{
$parts = self::parseConnectionString($connectionString);
$parts = self::parseConnectionString($connectionString, self::KEY_MAP);

if (!isset($parts["host"])) {
throw new \Error("Host must be provided in connection string");
Expand Down

0 comments on commit 361d93d

Please sign in to comment.