modify plugin name
This commit is contained in:
+10
-6
@@ -140,18 +140,20 @@ class Command extends Component
|
||||
|
||||
|
||||
/**
|
||||
* @param PDO $pdo
|
||||
* @return bool|int
|
||||
* @throws Exception
|
||||
*/
|
||||
private function _execute(PDO $pdo): bool|int
|
||||
private function _execute(): bool|int
|
||||
{
|
||||
try {
|
||||
$pdo = $this->db->masterInstance();
|
||||
|
||||
$result = $pdo->execute($this->sql, $this->params);
|
||||
|
||||
$this->db->release($pdo, true);
|
||||
} catch (\Throwable $exception) {
|
||||
$result = $this->logger->addError($this->sql . '. error: ' . $exception->getMessage(), 'mysql');
|
||||
} finally {
|
||||
$this->db->release($pdo, true);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -159,18 +161,20 @@ class Command extends Component
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @param PDO $pdo
|
||||
* @return array|int|bool|null
|
||||
* @throws Exception
|
||||
*/
|
||||
private function search(string $type, PDO $pdo): array|int|bool|null
|
||||
private function search(string $type): array|int|bool|null
|
||||
{
|
||||
try {
|
||||
$pdo = $this->db->slaveInstance();
|
||||
|
||||
$data = $pdo->{$type}($this->sql, $this->params);
|
||||
|
||||
$this->db->release($pdo, false);
|
||||
} catch (\Throwable $throwable) {
|
||||
$data = $this->logger->addError($this->sql . '. error: ' . $throwable->getMessage(), 'mysql');
|
||||
} finally {
|
||||
$this->db->release($pdo, false);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-5
@@ -94,7 +94,7 @@ class PDO implements StopHeartbeatCheck
|
||||
public function heartbeat_check(): void
|
||||
{
|
||||
if ($this->_timer === -1) {
|
||||
$this->_timer = Timer::tick(1000, fn() => $this->waite());
|
||||
$this->_timer = Timer::tick(1000, [$this, 'waite']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,10 +105,8 @@ class PDO implements StopHeartbeatCheck
|
||||
private function waite(): void
|
||||
{
|
||||
try {
|
||||
if ($this->_timer == -1) {
|
||||
$this->stopHeartbeatCheck();
|
||||
}
|
||||
if (time() - $this->_last > (int)Config::get('databases.pool.tick', 60)) {
|
||||
$tick = (int)Config::get('databases.pool.tick', 60);
|
||||
if ($this->_timer == -1 || time() - $this->_last > $tick) {
|
||||
$this->stopHeartbeatCheck();
|
||||
|
||||
$this->pdo = null;
|
||||
|
||||
Reference in New Issue
Block a user