diff --git a/src/PgSqlHandle.php b/src/PgSqlHandle.php index f742469..a87404b 100644 --- a/src/PgSqlHandle.php +++ b/src/PgSqlHandle.php @@ -372,13 +372,13 @@ final class PgSqlHandle implements Handle if (isset($this->statements[$name])) { $storage = $this->statements[$name]; + ++$storage->refCount; + if ($storage->promise instanceof Promise) { // Do not return promised prepared statement object, as the $names array may differ. yield $storage->promise; } - ++$storage->refCount; - return new PgSqlStatement($this, $name, $sql, $names); } diff --git a/src/PqHandle.php b/src/PqHandle.php index 3c10b7b..f795108 100644 --- a/src/PqHandle.php +++ b/src/PqHandle.php @@ -393,13 +393,13 @@ final class PqHandle implements Handle if (isset($this->statements[$name])) { $storage = $this->statements[$name]; + ++$storage->refCount; + if ($storage->promise instanceof Promise) { // Do not return promised prepared statement object, as the $names array may differ. yield $storage->promise; } - ++$storage->refCount; - return new PqStatement($this, $name, $sql, $names); }