This commit is contained in:
2023-07-31 23:08:59 +08:00
parent 45d0712cb2
commit 00a2125efc
15 changed files with 1334 additions and 1612 deletions
+11 -3
View File
@@ -19,6 +19,7 @@ use Kiri;
use Kiri\Exception\ConfigException;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use ReflectionException;
use Throwable;
/**
@@ -56,7 +57,9 @@ class Db implements ISqlBuilder
/**
* @return void
* @throws Exception
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws ReflectionException
*/
public static function beginTransaction(): void
{
@@ -78,8 +81,7 @@ class Db implements ISqlBuilder
try {
$result = call_user_func($closure, ...$params);
} catch (Throwable $throwable) {
error($throwable);
$result = addError($throwable->getMessage(), 'mysql');
$result = trigger_print_error($throwable->getMessage(), 'mysql');
} finally {
if ($result === false) {
static::rollback();
@@ -93,6 +95,9 @@ class Db implements ISqlBuilder
/**
* @return void
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws ReflectionException
*/
public static function commit(): void
{
@@ -102,6 +107,9 @@ class Db implements ISqlBuilder
/**
* @return void
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws ReflectionException
*/
public static function rollback(): void
{