Commit 85e8ff20 by Alexander Makarov

connection wasn't properly returned in case of being created

parent 9d3e293c
...@@ -68,13 +68,13 @@ class DbTarget extends Target ...@@ -68,13 +68,13 @@ class DbTarget extends Target
*/ */
public function getDbConnection() public function getDbConnection()
{ {
if ($this->_db !== null) { if ($this->_db === null) {
return $this->_db; $this->_db = \Yii::$application->getComponent($this->connectionID);
} if (!$this->_db instanceof \yii\db\dao\Connection) {
$this->_db = \Yii::$application->getComponent($this->connectionID); throw new \yii\base\Exception('DbTarget.connectionID must refer to a valid application component ID');
if (!$this->_db instanceof \yii\db\dao\Connection) { }
throw new \yii\base\Exception('DbTarget.connectionID must refer to a valid application component ID');
} }
return $this->_db;
} }
/** /**
......
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