eee
This commit is contained in:
+59
-55
@@ -248,61 +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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user