变更
This commit is contained in:
+14
-11
@@ -18,6 +18,7 @@ use Database\Mysql\PDO;
|
|||||||
use Database\Mysql\Schema;
|
use Database\Mysql\Schema;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Kiri;
|
use Kiri;
|
||||||
|
use Kiri\Context;
|
||||||
use Kiri\Abstracts\Component;
|
use Kiri\Abstracts\Component;
|
||||||
use Kiri\Abstracts\Config;
|
use Kiri\Abstracts\Config;
|
||||||
use Kiri\Events\EventProvider;
|
use Kiri\Events\EventProvider;
|
||||||
@@ -191,10 +192,10 @@ class Connection extends Component
|
|||||||
*/
|
*/
|
||||||
public function getPdo(): PDO
|
public function getPdo(): PDO
|
||||||
{
|
{
|
||||||
if (!$this->_pdo) {
|
if (!Context::hasContext('master:client')) {
|
||||||
$this->_pdo = $this->getMasterClient();
|
Context::setContext('master:client', $this->getMasterClient());
|
||||||
}
|
}
|
||||||
return $this->_pdo;
|
return Context::getContext('master:client');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -212,11 +213,12 @@ class Connection extends Component
|
|||||||
*/
|
*/
|
||||||
public function rollback()
|
public function rollback()
|
||||||
{
|
{
|
||||||
if ($this->_pdo->inTransaction()) {
|
$pdo = $this->getPdo();
|
||||||
$this->_pdo->rollback();
|
if ($pdo->inTransaction()) {
|
||||||
|
$pdo->rollback();
|
||||||
}
|
}
|
||||||
$this->release($this->_pdo, true);
|
$this->release($pdo, true);
|
||||||
$this->_pdo = null;
|
Context::remove('master:client');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -225,11 +227,12 @@ class Connection extends Component
|
|||||||
*/
|
*/
|
||||||
public function commit()
|
public function commit()
|
||||||
{
|
{
|
||||||
if ($this->_pdo->inTransaction()) {
|
$pdo = $this->getPdo();
|
||||||
$this->_pdo->commit();
|
if ($pdo->inTransaction()) {
|
||||||
|
$pdo->commit();
|
||||||
}
|
}
|
||||||
$this->release($this->_pdo, true);
|
$this->release($pdo, true);
|
||||||
$this->_pdo = null;
|
Context::remove('master:client');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user