Skip to content

Commit

Permalink
handle mysql master / slave connection
Browse files Browse the repository at this point in the history
  • Loading branch information
jdeniau committed Oct 9, 2020
1 parent dd1814e commit 4e7329c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions adapters/Doctrine/DBAL/ConnectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ public function createConnection(array $params, Configuration $config = null, Ev
$slave['path'] = str_replace('__DBNAME__', $dbName, $slave['path']);
}
}
} elseif ('pdo_mysql' === $params['driver']) {
if (isset($params['dbname'])) {
$params['dbname'] = $this->getDbNameFromEnv($params['dbname']);
}

if (isset($params['master']['dbname'])) {
$params['master']['dbname'] = $this->getDbNameFromEnv($params['master']['dbname']);
}

if (!empty($params['slaves'])) {
foreach ($params['slaves'] as &$slave) {
$slave['dbname'] = $this->getDbNameFromEnv($slave['dbname']);
}
}
} else {
$params['dbname'] = $dbName;
}
Expand Down

0 comments on commit 4e7329c

Please sign in to comment.