From 400ebf61c65a1c8df58a164588e04494ca802d80 Mon Sep 17 00:00:00 2001 From: Pinga <121483313+getpinga@users.noreply.github.com> Date: Fri, 3 Feb 2023 11:50:20 +0200 Subject: [PATCH] Update PdoDatabase.php --- src/PdoDatabase.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/PdoDatabase.php b/src/PdoDatabase.php index ffa2d6a..c65e27e 100644 --- a/src/PdoDatabase.php +++ b/src/PdoDatabase.php @@ -89,8 +89,14 @@ private function __construct(PDO $pdoInstance = null, PdoDsn $pdoDsn = null, $pr * @param bool|null (optional) $preserveOldState whether the old state of the PDO instance should be preserved * @return static the new instance */ - public static function fromPdo(PDO $pdoInstance, $preserveOldState = null) { - return new static($pdoInstance, null, $preserveOldState); + public static function fromPdo($pdoInstance, $preserveOldState = null) { + if ($pdoInstance instanceof PDO) { + return new static($pdoInstance, null, $preserveOldState); + } else if ($pdoInstance instanceof Swoole\Coroutine\MySQL) { + return new static($pdoInstance, null, $preserveOldState); + } else { + throw new Exception("Invalid argument type. Expected PDO or Swoole\Coroutine\MySQL."); + } } /**