eee
This commit is contained in:
+27
-1
@@ -229,7 +229,33 @@ class Command extends Component
|
|||||||
*/
|
*/
|
||||||
public function delete(): bool
|
public function delete(): bool
|
||||||
{
|
{
|
||||||
return (bool)$this->_prepare();
|
$client = $this->connection->getConnection();
|
||||||
|
try {
|
||||||
|
$startTime = microtime(true);
|
||||||
|
if (($prepare = $client->prepare($this->sql)) === false) {
|
||||||
|
throw new Exception('(' . $prepare->errorInfo()[0] . ')' . $prepare->errorInfo()[2]);
|
||||||
|
}
|
||||||
|
if ($prepare->execute($this->params) === false) {
|
||||||
|
throw new Exception('(' . $prepare->errorInfo()[0] . ')' . $prepare->errorInfo()[2]);
|
||||||
|
}
|
||||||
|
$prepare->closeCursor();
|
||||||
|
|
||||||
|
$this->connection->println($startTime, microtime(true), $this->sql, $this->params);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch (Throwable $throwable) {
|
||||||
|
$this->getLogger()->json_log($throwable);
|
||||||
|
|
||||||
|
if ($this->isRefresh($throwable)) {
|
||||||
|
return $this->_prepare();
|
||||||
|
}
|
||||||
|
|
||||||
|
$errorMsg = $throwable->getMessage() . PHP_EOL . ' Sql: ' . $this->sql . '.' . json_encode($this->params, JSON_UNESCAPED_UNICODE);
|
||||||
|
|
||||||
|
return $this->getLogger()->logCategory($errorMsg . PHP_EOL, 'mysql');
|
||||||
|
} finally {
|
||||||
|
$this->connection->release($client);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user