改名
This commit is contained in:
@@ -3,6 +3,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Snowflake\Pool;
|
||||
|
||||
use Closure;
|
||||
use Exception;
|
||||
use HttpServer\Http\Context;
|
||||
use PDO;
|
||||
@@ -46,6 +47,8 @@ class Connection extends Component
|
||||
if (!Context::hasContext('begin_' . $coroutineName)) {
|
||||
Context::setContext('begin_' . $coroutineName, 0);
|
||||
}
|
||||
Context::increment('begin_' . $coroutineName, 1);
|
||||
|
||||
$connection = Context::getContext($coroutineName);
|
||||
if ($connection instanceof PDO && !$connection->inTransaction()) {
|
||||
$connection->beginTransaction();
|
||||
@@ -90,7 +93,7 @@ class Connection extends Component
|
||||
/**
|
||||
* @param mixed $config
|
||||
* @param bool $isMaster
|
||||
* @return mixed
|
||||
* @return PDO|null
|
||||
* @throws Exception
|
||||
*/
|
||||
public function get(mixed $config, bool $isMaster = false): ?PDO
|
||||
@@ -111,9 +114,9 @@ class Connection extends Component
|
||||
/**
|
||||
* @param $coroutineName
|
||||
* @param $config
|
||||
* @return \Closure
|
||||
* @return Closure
|
||||
*/
|
||||
public function create($coroutineName, $config)
|
||||
public function create($coroutineName, $config): Closure
|
||||
{
|
||||
return static function () use ($coroutineName, $config) {
|
||||
if (Coroutine::getCid() === -1) {
|
||||
|
||||
Reference in New Issue
Block a user