Skip to content

Commit

Permalink
改进多数据库连接的切换
Browse files Browse the repository at this point in the history
  • Loading branch information
liu21st committed Dec 1, 2017
1 parent 97aa420 commit dc72288
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/db/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,13 @@ public function getTable($name = '')
public function connect($config = [], $name = false)
{
$this->connection = Connection::instance($config, $name);
$this->prefix = $this->connection->getConfig('prefix');
$query = $this->connection->getConfig('query');

if (__CLASS__ != $query) {
return new $query($this->connection);
}

$this->prefix = $this->connection->getConfig('prefix');

return $this;
}
Expand Down

0 comments on commit dc72288

Please sign in to comment.