Skip to content

Commit a207fbe

Browse files
committed
support database connect
1 parent 1d3ee76 commit a207fbe

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"php": "^8.1",
1414
"react/async": "^4 || ^3 || ^2",
1515
"illuminate/database": "^11.19",
16-
"reactphp-x/mysql-pool": "^2.0@dev"
16+
"reactphp-x/mysql-pool": "^2.0"
1717
},
1818
"autoload": {
1919
"psr-4": {

src/AsyncMysqlConnector.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
class AsyncMysqlConnector implements ConnectorInterface
99
{
1010

11-
protected static $pool;
11+
protected static $connectToPoll;
1212

1313
public function connect($config)
1414
{
1515

16-
if (static::$pool) {
17-
return static::$pool;
16+
if (isset(static::$connectToPoll[$config['name']])) {
17+
return static::$connectToPoll[$config['name']];
1818
}
1919

2020
$username = $config['username'];
@@ -27,7 +27,7 @@ public function connect($config)
2727
}
2828
$database = $config['database'];
2929

30-
return static::$pool = new Pool(
30+
return static::$connectToPoll[$config['name']] = new Pool(
3131
$username . ':' . $password . '@' . $host . '/' . $database . '?charset=' . $charset.'&idle='.($config['idle'] ?? 30),
3232
$config['pool']['min_connections'] ?? 1,
3333
$config['pool']['max_connections'] ?? 10,

0 commit comments

Comments
 (0)