feat: allow overriding the default output test
This commit is contained in:
@@ -23,7 +23,7 @@ class Connection
|
|||||||
* @return OdbcResultSet|resource|string
|
* @return OdbcResultSet|resource|string
|
||||||
* @throws SqlException
|
* @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);
|
$statement = PDOWithFilters::prepare($sql);
|
||||||
$success = $statement->execute(!empty($values) ? $values : null);
|
$success = $statement->execute(!empty($values) ? $values : null);
|
||||||
@@ -32,7 +32,7 @@ class Connection
|
|||||||
throw new SqlException('SQL There was an error executing the request');
|
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);
|
$rows = $statement->fetchAll($fetchMode);
|
||||||
if (!is_array($rows)) {
|
if (!is_array($rows)) {
|
||||||
throw new SqlException('PDO Unable to retrieve the result');
|
throw new SqlException('PDO Unable to retrieve the result');
|
||||||
|
|||||||
Reference in New Issue
Block a user