Skip to content

Commit

Permalink
Update PdoDatabase.php
Browse files Browse the repository at this point in the history
  • Loading branch information
getpinga authored Feb 3, 2023
1 parent 7ba20a8 commit 400ebf6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/PdoDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
}

/**
Expand Down

0 comments on commit 400ebf6

Please sign in to comment.