This commit is contained in:
2020-09-18 17:32:49 +08:00
parent 0b5dc1e237
commit df79a4fa13
2 changed files with 5 additions and 4 deletions
+2 -1
View File
@@ -218,7 +218,8 @@ class Command extends Component
*/ */
private function search($type) private function search($type)
{ {
if (!(($connect = $this->db->getConnect($this->sql)) instanceof PDO)) { $connect = $this->db->getConnect($this->sql);
if (!($connect instanceof PDO)) {
return null; return null;
} }
if (!($query = $connect->query($this->sql))) return null; if (!($query = $connect->query($this->sql))) return null;
+3 -3
View File
@@ -198,9 +198,6 @@ class Connection extends Pool
*/ */
public function getConnection(array $config, $isMaster = false) public function getConnection(array $config, $isMaster = false)
{ {
if ($this->creates === 0) {
$this->creates = Timer::tick(10000, [$this, 'Heartbeat_detection']);
}
$coroutineName = $this->name($config['cds'], $isMaster); $coroutineName = $this->name($config['cds'], $isMaster);
if (!isset($this->hasCreate[$coroutineName])) { if (!isset($this->hasCreate[$coroutineName])) {
$this->hasCreate[$coroutineName] = 0; $this->hasCreate[$coroutineName] = 0;
@@ -243,6 +240,9 @@ class Connection extends Pool
if ($number = Context::getContext('begin_' . $coroutineName, Coroutine::getCid())) { if ($number = Context::getContext('begin_' . $coroutineName, Coroutine::getCid())) {
$number > 0 && $client->beginTransaction(); $number > 0 && $client->beginTransaction();
} }
if ($this->creates === 0) {
$this->creates = Timer::tick(10000, [$this, 'Heartbeat_detection']);
}
return $client; return $client;
} }