Revert "改名"
This reverts commit fdf58326
This commit is contained in:
@@ -13,8 +13,8 @@ namespace Database;
|
|||||||
use Database\Base\Getter;
|
use Database\Base\Getter;
|
||||||
use Database\Traits\HasBase;
|
use Database\Traits\HasBase;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Kiri\Exception\NotFindClassException;
|
|
||||||
use Kiri;
|
use Kiri;
|
||||||
|
use Kiri\Exception\NotFindClassException;
|
||||||
use Kiri\ToArray;
|
use Kiri\ToArray;
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
use Swoole\Coroutine;
|
use Swoole\Coroutine;
|
||||||
@@ -113,24 +113,23 @@ class Model extends Base\Model
|
|||||||
return $logger->addError(FIND_OR_CREATE_MESSAGE, 'mysql');
|
return $logger->addError(FIND_OR_CREATE_MESSAGE, 'mysql');
|
||||||
}
|
}
|
||||||
Db::beginTransaction();
|
Db::beginTransaction();
|
||||||
|
try {
|
||||||
/** @var static $select */
|
/** @var static $select */
|
||||||
$select = static::query()->where($condition)->first();
|
$select = static::query()->where($condition)->first();
|
||||||
var_dump($select);
|
|
||||||
if (empty($select)) {
|
if (empty($select)) {
|
||||||
$select = new static();
|
$select = new static();
|
||||||
$select->attributes = $attributes;
|
$select->attributes = $attributes;
|
||||||
if (!$select->save()) {
|
if (!$select->save()) {
|
||||||
var_dump('end rollback');
|
throw new Exception($select->getLastError());
|
||||||
Db::rollback();
|
|
||||||
return $logger->addError($select->getLastError(), 'mysql');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var_dump('end commit');
|
|
||||||
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
|
|
||||||
return $select;
|
return $select;
|
||||||
|
} catch (\Throwable $throwable) {
|
||||||
|
Db::rollback();
|
||||||
|
return $logger->addError($throwable->getMessage(), 'mysql');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user