Commit c545ef7e authored by Kim Hemsø Rasmussen's avatar Kim Hemsø Rasmussen

Set platform instance if passed in connection params and remove it from there.

parent d1eca406
...@@ -211,6 +211,15 @@ class Connection implements DriverConnection ...@@ -211,6 +211,15 @@ class Connection implements DriverConnection
unset($this->_params['pdo']); unset($this->_params['pdo']);
} }
if (isset($params["platform"])) {
if ( ! $params['platform'] instanceof Platforms\AbstractPlatform) {
throw DBALException::invalidPlatformSpecified();
}
$this->platform = $params["platform"];
unset($this->_params["platform"]);
}
// Create default config and event manager if none given // Create default config and event manager if none given
if ( ! $config) { if ( ! $config) {
$config = new Configuration(); $config = new Configuration();
...@@ -386,18 +395,12 @@ class Connection implements DriverConnection ...@@ -386,18 +395,12 @@ class Connection implements DriverConnection
*/ */
private function detectDatabasePlatform() private function detectDatabasePlatform()
{ {
if ( ! isset($this->_params['platform'])) { $version = $this->getDatabasePlatformVersion();
$version = $this->getDatabasePlatformVersion();
if (null !== $version) { if (null !== $version) {
$this->platform = $this->_driver->createDatabasePlatformForVersion($version); $this->platform = $this->_driver->createDatabasePlatformForVersion($version);
} else {
$this->platform = $this->_driver->getDatabasePlatform();
}
} elseif ($this->_params['platform'] instanceof Platforms\AbstractPlatform) {
$this->platform = $this->_params['platform'];
} else { } else {
throw DBALException::invalidPlatformSpecified(); $this->platform = $this->_driver->getDatabasePlatform();
} }
$this->platform->setEventManager($this->_eventManager); $this->platform->setEventManager($this->_eventManager);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment