This commit is contained in:
2023-04-02 20:13:19 +08:00
parent 735c077f46
commit 0a323b5f62
2 changed files with 9 additions and 13 deletions
+6 -10
View File
@@ -118,7 +118,7 @@ class Connection extends Component
public function connectPoolInstance()
{
$pool = $this->slaveConfig['pool'] ?? ['max' => 10, 'min' => 1];
$this->connection->initConnections($this->cds, $pool['max']);
}
@@ -181,14 +181,16 @@ class Connection extends Component
/**
* @param bool $restore
* @return PDO
* @throws Exception
*/
public function getPdo(): PDO
public function getPdo(bool $restore = false): PDO
{
if (!Db::inTransactionsActive()) {
return $this->getMasterClient();
if ($restore === true) {
return Context::setContext($this->cds, $this->getMasterClient());
}
if (!Db::inTransactionsActive()) return $this->getMasterClient();
if (!Context::hasContext($this->cds)) {
return Context::setContext($this->cds, $this->getMasterClient());
} else {
@@ -245,12 +247,6 @@ class Connection extends Component
}
public function restore()
{
Context::remove($this->cds);
}
/**
*
* 回收链接