modify plugin name
This commit is contained in:
+10
-18
@@ -10,10 +10,8 @@ declare(strict_types=1);
|
|||||||
namespace Database;
|
namespace Database;
|
||||||
|
|
||||||
|
|
||||||
use Database\Mysql\PDO;
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Kiri\Abstracts\Component;
|
use Kiri\Abstracts\Component;
|
||||||
use Kiri\Core\Json;
|
|
||||||
use PDOStatement;
|
use PDOStatement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -113,29 +111,23 @@ class Command extends Component
|
|||||||
*/
|
*/
|
||||||
private function execute(string $type): int|bool|array|string|null
|
private function execute(string $type): int|bool|array|string|null
|
||||||
{
|
{
|
||||||
$pdo = $this->db->getConnect($this->sql);
|
|
||||||
$time = microtime(true);
|
$time = microtime(true);
|
||||||
if ($type !== static::EXECUTE) {
|
|
||||||
$result = $this->search($type, $pdo);
|
$result = $type !== static::EXECUTE ? $this->search($type) : $this->_execute();
|
||||||
} else {
|
|
||||||
$result = $this->_execute($pdo);
|
$this->logger->debug('Mysql:' . $this->print_r($time));
|
||||||
}
|
|
||||||
return $this->_timeout_log($time, $result);
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param float $time
|
* @param $time
|
||||||
* @param mixed $result
|
* @return string
|
||||||
* @return mixed
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
private function _timeout_log(float $time, mixed $result): mixed
|
private function print_r($time): string
|
||||||
{
|
{
|
||||||
if (microtime(true) - $time >= 0.02) {
|
return print_r([$this->sql, $this->params], true) . (microtime(true) - $time);
|
||||||
$this->logger->warning('Mysql:' . Json::encode([$this->sql, $this->params]) . (microtime(true) - $time));
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user