This commit is contained in:
2026-06-30 22:07:04 +08:00
parent 06074c38c1
commit 14448d824a
+60 -60
View File
@@ -154,7 +154,7 @@ class Connection extends Component
/**
* @return string
*/
private function getName(): string
public function getName(): string
{
return strtolower($this->driver) . '.' . $this->cds;
}
@@ -248,65 +248,65 @@ class Connection extends Component
}
/**
* @throws
* 事务回滚
*/
public function rollback(): void
{
$this->storey--;
if ($this->storey == 0) {
if (!Context::exists($this->cds)) {
return;
}
$pdo = $this->getTransactionClient();
if ($pdo->inTransaction()) {
$pdo->rollback();
}
$this->release($pdo);
Context::remove($this->cds);
}
}
/**
* @throws
* 事务提交
*/
public function commit(): void
{
$this->storey--;
if ($this->storey == 0) {
if (!Context::exists($this->cds)) {
return;
}
$pdo = $this->getTransactionClient();
if ($pdo->inTransaction()) {
$pdo->commit();
}
$this->release($pdo);
Context::remove($this->cds);
}
}
/**
* @return void
* @throws
*/
public function clear(): void
{
/** @var PDO $pdo */
$pdo = Context::get($this->cds);
if ($pdo === null) {
return;
}
if ($this->inTransaction()) {
$pdo->rollback();
}
$this->release($pdo);
Context::remove($this->cds);
$this->storey = 0;
}
/**
* @throws
* 事务回滚
*/
public function rollback(): void
{
$this->storey--;
if ($this->storey == 0) {
if (!Context::exists($this->cds)) {
return;
}
$pdo = $this->getTransactionClient();
if ($pdo->inTransaction()) {
$pdo->rollback();
}
$this->release($pdo);
Context::remove($this->cds);
}
}
/**
* @throws
* 事务提交
*/
public function commit(): void
{
$this->storey--;
if ($this->storey == 0) {
if (!Context::exists($this->cds)) {
return;
}
$pdo = $this->getTransactionClient();
if ($pdo->inTransaction()) {
$pdo->commit();
}
$this->release($pdo);
Context::remove($this->cds);
}
}
/**
* @return void
* @throws
*/
public function clear(): void
{
/** @var PDO $pdo */
$pdo = Context::get($this->cds);
if ($pdo === null) {
return;
}
if ($this->inTransaction()) {
$pdo->rollback();
}
$this->release($pdo);
Context::remove($this->cds);
$this->storey = 0;
}
/**