改名
This commit is contained in:
+10
-5
@@ -118,37 +118,42 @@ class Command extends Component
|
|||||||
*/
|
*/
|
||||||
private function execute($type, $isInsert = null, $hasAutoIncrement = null): int|bool|array|string|null
|
private function execute($type, $isInsert = null, $hasAutoIncrement = null): int|bool|array|string|null
|
||||||
{
|
{
|
||||||
try {
|
|
||||||
$time = microtime(true);
|
$time = microtime(true);
|
||||||
|
try {
|
||||||
if ($type === static::EXECUTE) {
|
if ($type === static::EXECUTE) {
|
||||||
$result = $this->insert_or_change($isInsert, $hasAutoIncrement);
|
$result = $this->insert_or_change($isInsert, $hasAutoIncrement);
|
||||||
} else {
|
} else {
|
||||||
$result = $this->search($type);
|
$result = $this->search($type);
|
||||||
}
|
}
|
||||||
$this->setExecuteLog($time);
|
|
||||||
if ($this->prepare) {
|
if ($this->prepare) {
|
||||||
$this->prepare->closeCursor();
|
$this->prepare->closeCursor();
|
||||||
}
|
}
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
$result = $this->addError($this->sql . '. error: ' . $exception->getMessage(), 'mysql');
|
$message = $this->sql . '. error: ' . $exception->getMessage();
|
||||||
|
|
||||||
|
$result = $this->addError($message, 'mysql');
|
||||||
} finally {
|
} finally {
|
||||||
return $result;
|
return $this->setExecuteLog($time, $result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $time
|
* @param $time
|
||||||
|
* @param $result
|
||||||
|
* @return mixed
|
||||||
* @throws ComponentException
|
* @throws ComponentException
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private function setExecuteLog($time)
|
private function setExecuteLog($time, $result): mixed
|
||||||
{
|
{
|
||||||
$export['sql'] = $this->sql;
|
$export['sql'] = $this->sql;
|
||||||
$export['param'] = $this->params;
|
$export['param'] = $this->params;
|
||||||
$export['time'] = microtime(true) - $time;
|
$export['time'] = microtime(true) - $time;
|
||||||
|
|
||||||
logger()->debug(print_r($export, true), 'mysql');
|
logger()->debug(print_r($export, true), 'mysql');
|
||||||
|
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user