变更
This commit is contained in:
+2
-15
@@ -353,7 +353,7 @@ class PDO implements StopHeartbeatCheck
|
|||||||
public function _pdo(): \PDO
|
public function _pdo(): \PDO
|
||||||
{
|
{
|
||||||
if (!($this->pdo instanceof \PDO)) {
|
if (!($this->pdo instanceof \PDO)) {
|
||||||
$this->pdo = $this->newClient();
|
$this->newClient();
|
||||||
}
|
}
|
||||||
return $this->pdo;
|
return $this->pdo;
|
||||||
}
|
}
|
||||||
@@ -364,14 +364,6 @@ class PDO implements StopHeartbeatCheck
|
|||||||
*/
|
*/
|
||||||
private function newClient(): \PDO
|
private function newClient(): \PDO
|
||||||
{
|
{
|
||||||
while ($this->group->count() > 0) {
|
|
||||||
Coroutine::sleep(0.0001);
|
|
||||||
}
|
|
||||||
$this->group->add();
|
|
||||||
Coroutine::create(function () {
|
|
||||||
Coroutine::defer(function () {
|
|
||||||
$this->group->done();
|
|
||||||
});
|
|
||||||
$link = new \PDO('mysql:dbname=' . $this->dbname . ';host=' . $this->cds, $this->username, $this->password, [
|
$link = new \PDO('mysql:dbname=' . $this->dbname . ';host=' . $this->cds, $this->username, $this->password, [
|
||||||
\PDO::ATTR_EMULATE_PREPARES => false,
|
\PDO::ATTR_EMULATE_PREPARES => false,
|
||||||
\PDO::ATTR_CASE => \PDO::CASE_NATURAL,
|
\PDO::ATTR_CASE => \PDO::CASE_NATURAL,
|
||||||
@@ -388,12 +380,7 @@ class PDO implements StopHeartbeatCheck
|
|||||||
if (Db::inTransactionsActive()) {
|
if (Db::inTransactionsActive()) {
|
||||||
$link->beginTransaction();
|
$link->beginTransaction();
|
||||||
}
|
}
|
||||||
|
return $this->pdo = $link;
|
||||||
$this->pdo = $link;
|
|
||||||
});
|
|
||||||
$this->group->wait();
|
|
||||||
|
|
||||||
return $this->pdo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user