From e2bf1acd4831aa8d3c70e725816767c8dfddbe44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Tue, 27 Apr 2021 16:20:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Database/Command.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Database/Command.php b/Database/Command.php index 30a6cf8c..d8479a63 100644 --- a/Database/Command.php +++ b/Database/Command.php @@ -125,6 +125,9 @@ class Command extends Component } else { $result = $this->search($type); } + if (microtime(true) - $time >= 0.03) { + $this->warning('execute sql `' . $this->sql . '` use time ' . (microtime(true) - $time)); + } if ($this->prepare) { $this->prepare->closeCursor(); } @@ -169,13 +172,6 @@ class Command extends Component if (!($connect instanceof PDO)) { return $this->addError('数据库繁忙, 请稍后再试.'); } - - $time = microtime(true); - defer(function () use ($time) { - if (microtime(true) - $time >= 0.03) { - $this->warning('execute sql `' . $this->sql . '` use time ' . (microtime(true) - $time)); - } - }); if (!($query = $connect->query($this->sql))) { return $this->addError($connect->errorInfo()[2] ?? '数据库异常, 请稍后再试.'); }