From d9d3eed6ff8cf04eacc3430ad5cb987ce05597d0 Mon Sep 17 00:00:00 2001 From: Hector Cortez Date: Fri, 12 Oct 2012 16:57:47 -0400 Subject: [PATCH] BUG 9321 executeQuery() does not return the number of records affected..SLOVED - ExecuteQuery() is supposed to return the number of records affected by DELETE, UPDATE and INSERT commands. - Adjustment in the number of records for different Engines. --- .../thirdparty/creole/drivers/mssql/MSSQLConnection.php | 3 ++- workflow/engine/classes/class.pmFunctions.php | 7 ++++--- workflow/engine/classes/class.pmScript.php | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/gulliver/thirdparty/creole/drivers/mssql/MSSQLConnection.php b/gulliver/thirdparty/creole/drivers/mssql/MSSQLConnection.php index 2ed187a73..688eb48bd 100755 --- a/gulliver/thirdparty/creole/drivers/mssql/MSSQLConnection.php +++ b/gulliver/thirdparty/creole/drivers/mssql/MSSQLConnection.php @@ -192,7 +192,8 @@ class MSSQLConnection extends ConnectionCommon implements Connection { throw new SQLException('Could not execute update', mssql_get_last_message(), $sql); } - return $this->getUpdateCount(); + return (int) mssql_rows_affected($this->dblink); + // return $this->getUpdateCount(); } /** diff --git a/workflow/engine/classes/class.pmFunctions.php b/workflow/engine/classes/class.pmFunctions.php index 61ac34afc..0bf6eee64 100755 --- a/workflow/engine/classes/class.pmFunctions.php +++ b/workflow/engine/classes/class.pmFunctions.php @@ -250,19 +250,20 @@ function executeQuery ($SqlStatement, $DBConnectionUID = 'workflow', $aParameter break; case preg_match( "/^INSERT\s/i", $statement ): $rs = $con->executeUpdate( $SqlStatement ); + $result = $con->getUpdateCount(); $con->commit(); //$result = $lastId->getId(); - $result = 1; + // $result = 1; break; case preg_match( "/^UPDATE\s/i", $statement ): $rs = $con->executeUpdate( $SqlStatement ); - $con->commit(); $result = $con->getUpdateCount(); + $con->commit(); break; case preg_match( "/^DELETE\s/i", $statement ): $rs = $con->executeUpdate( $SqlStatement ); - $con->commit(); $result = $con->getUpdateCount(); + $con->commit(); break; } } else { diff --git a/workflow/engine/classes/class.pmScript.php b/workflow/engine/classes/class.pmScript.php index cb376c524..c0695a214 100755 --- a/workflow/engine/classes/class.pmScript.php +++ b/workflow/engine/classes/class.pmScript.php @@ -679,6 +679,7 @@ function executeQueryOci ($sql, $connection, $aParameter = array()) } } $objExecute = oci_execute( $stid, OCI_DEFAULT ); + $result = oci_num_rows ($stid); if ($objExecute) { oci_commit( $conn ); } else { @@ -688,7 +689,7 @@ function executeQueryOci ($sql, $connection, $aParameter = array()) oci_free_statement( $stid ); oci_close( $conn ); if ($isValid) { - return true; + return $result; } else { return oci_error(); }