From 27e80613c776e6915b7fdca65b7f6391d9cc74d5 Mon Sep 17 00:00:00 2001 From: Guillermo Pages Date: Mon, 27 Sep 2021 12:06:32 +0200 Subject: [PATCH] feat: allow overriding the default output test --- src/Db/Connection.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Db/Connection.php b/src/Db/Connection.php index 1c9e613..f33d4c3 100644 --- a/src/Db/Connection.php +++ b/src/Db/Connection.php @@ -23,7 +23,7 @@ class Connection * @return OdbcResultSet|resource|string * @throws SqlException */ - public static function execute($sql, $values = array(), $fetchMode = \PDO::FETCH_ASSOC) + public static function execute($sql, $values = array(), $fetchMode = \PDO::FETCH_ASSOC, $hasOutput = null) { $statement = PDOWithFilters::prepare($sql); $success = $statement->execute(!empty($values) ? $values : null); @@ -32,7 +32,7 @@ class Connection throw new SqlException('SQL There was an error executing the request'); } - if (strpos($sql, "SELECT") !== false || strpos($sql, "OUTPUT INSERTED") !== false) { + if ((strpos($sql, "SELECT") < 6 || strpos($sql, "OUTPUT INSERTED") !== false) && (($hasOutput !== null && $hasOutput !== false) || $hasOutput === null)) { $rows = $statement->fetchAll($fetchMode); if (!is_array($rows)) { throw new SqlException('PDO Unable to retrieve the result');