Skip to content

Commit 1e633cd

Browse files
committed
Support reconnect
1 parent 2d7b6b0 commit 1e633cd

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/DatabaseManager.php

+16
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,22 @@ class DatabaseManager extends BaseDatabaseManager
1818
*/
1919
protected static array $pools = [];
2020

21+
/**
22+
* @inheritDoc
23+
*/
24+
public function __construct(...$args)
25+
{
26+
parent::__construct(...$args);
27+
$this->reconnector = function ($connection) {
28+
$name = $connection->getNameWithReadWriteType();
29+
[$database, $type] = $this->parseConnectionName($name);
30+
$fresh = $this->configure(
31+
$this->makeConnection($database), $type
32+
);
33+
$connection->setPdo($fresh->getRawPdo());
34+
};
35+
}
36+
2137
/**
2238
* Get connection
2339
*

0 commit comments

Comments
 (0)