This commit is contained in:
2023-02-07 17:05:21 +08:00
parent dfbfa701e5
commit add511ed2a
+3 -3
View File
@@ -117,14 +117,14 @@ class Connection extends Component
*/ */
public function connectPoolInstance() public function connectPoolInstance()
{ {
if (!empty($this->slaveConfig) && $this->cds != $this->slaveConfig['cds']) { if (!empty($this->slaveConfig) && isset($this->slaveConfig['cds'])) {
$pool = $this->pool ?? ['max' => 10, 'min' => 1]; $pool = $this->pool ?? ['max' => 10, 'min' => 1];
$this->connection->initConnections('Mysql:' . $this->slaveConfig['cds'], $pool['max']); $this->connection->initConnections($this->slaveConfig['cds'] . 'slave', $pool['max']);
} else { } else {
$pool = $this->slaveConfig['pool'] ?? ['max' => 10, 'min' => 1]; $pool = $this->slaveConfig['pool'] ?? ['max' => 10, 'min' => 1];
$this->connection->initConnections('Mysql:' . $this->cds, $pool['max']); $this->connection->initConnections($this->cds . 'master', $pool['max']);
} }
} }