Skip to content

Commit 2d7b6b0

Browse files
authored
Fix heartbeat for mongodb
1 parent 360e42d commit 2d7b6b0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/DatabaseManager.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ public function connection($name = null)
4343
$this->closeAndFreeConnection($connection);
4444
});
4545
$pool->setHeartbeatChecker(function ($connection) {
46-
$connection->select('select 1');
46+
if (in_array($connection->getDriverName(), ['mysql', 'pgsql', 'sqlite', 'sqlsrv'])) {
47+
$connection->select('select 1');
48+
} elseif ($connection->getDriverName() === 'mongodb') {
49+
$connection->command(['ping' => 1]);
50+
}
4751
});
4852
static::$pools[$name] = $pool;
4953
}

0 commit comments

Comments
 (0)