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."); + } } /**