From 881693402a95fc5cecb23b097bcf44d1684ed8c7 Mon Sep 17 00:00:00 2001 From: Guillermo Pages Date: Mon, 13 Sep 2021 19:49:50 +0200 Subject: [PATCH] fix: bad cursor state --- src/Db/Connection.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Db/Connection.php b/src/Db/Connection.php index c04171f..4b3199c 100644 --- a/src/Db/Connection.php +++ b/src/Db/Connection.php @@ -32,13 +32,17 @@ class Connection throw new SqlException('SQL There was an error executing the request'); } - $rows = $statement->fetchAll($fetchMode); - - if (!is_array($rows)) { - throw new SqlException('PDO Unable to retrieve the result'); + if (strpos($sql, "SELECT") !== false) { + $rows = $statement->fetchAll($fetchMode); + if (!is_array($rows)) { + throw new SqlException('PDO Unable to retrieve the result'); + } + return new OdbcResultSet($rows); } - return new OdbcResultSet($rows); + $statement->closeCursor(); + + return true; } /**