From ff3a23f442a17099bcec9264511a98cb272d05ba Mon Sep 17 00:00:00 2001 From: v-kaywon Date: Mon, 3 Apr 2017 12:43:08 -0700 Subject: [PATCH] got rid of execReturn check since SQL_SUCCESS is 0 --- source/pdo_sqlsrv/pdo_dbh.cpp | 14 ++++++-------- source/pdo_sqlsrv/pdo_stmt.cpp | 18 ++++++++---------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/source/pdo_sqlsrv/pdo_dbh.cpp b/source/pdo_sqlsrv/pdo_dbh.cpp index 9c2b9342..02334b67 100644 --- a/source/pdo_sqlsrv/pdo_dbh.cpp +++ b/source/pdo_sqlsrv/pdo_dbh.cpp @@ -695,19 +695,17 @@ zend_long pdo_sqlsrv_dbh_do( pdo_dbh_t *dbh, const char *sql, size_t sql_len TSR // since the user can give us a compound statement, we return the row count for the last set, and since the row count // isn't guaranteed to be valid until all the results have been fetched, we fetch them all first. - if ( execReturn ) { - if ( execReturn != SQL_NO_DATA && core_sqlsrv_has_any_result( driver_stmt TSRMLS_CC )) { + if ( execReturn != SQL_NO_DATA && core_sqlsrv_has_any_result( driver_stmt TSRMLS_CC )) { - SQLRETURN r = SQL_SUCCESS; + SQLRETURN r = SQL_SUCCESS; - do { + do { - rows = core::SQLRowCount( driver_stmt TSRMLS_CC ); + rows = core::SQLRowCount( driver_stmt TSRMLS_CC ); - r = core::SQLMoreResults( driver_stmt TSRMLS_CC ); + r = core::SQLMoreResults( driver_stmt TSRMLS_CC ); - } while ( r != SQL_NO_DATA ); - } + } while ( r != SQL_NO_DATA ); } // returning -1 forces PDO to return false, which signals an error occurred. SQLRowCount returns -1 for a number of cases diff --git a/source/pdo_sqlsrv/pdo_stmt.cpp b/source/pdo_sqlsrv/pdo_stmt.cpp index 9fe4b451..6d117063 100644 --- a/source/pdo_sqlsrv/pdo_stmt.cpp +++ b/source/pdo_sqlsrv/pdo_stmt.cpp @@ -554,17 +554,15 @@ int pdo_sqlsrv_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC) SQLRETURN execReturn = core_sqlsrv_execute( driver_stmt TSRMLS_CC, query, query_len ); - if ( execReturn ) { - if ( execReturn == SQL_NO_DATA ) { - stmt->column_count = 0; - stmt->row_count = 0; - } - else { - stmt->column_count = core::SQLNumResultCols( driver_stmt TSRMLS_CC ); + if ( execReturn == SQL_NO_DATA ) { + stmt->column_count = 0; + stmt->row_count = 0; + } + else { + stmt->column_count = core::SQLNumResultCols( driver_stmt TSRMLS_CC ); - // return the row count regardless if there are any rows or not - stmt->row_count = core::SQLRowCount( driver_stmt TSRMLS_CC ); - } + // return the row count regardless if there are any rows or not + stmt->row_count = core::SQLRowCount( driver_stmt TSRMLS_CC ); } // workaround for a bug in the PDO driver manager. It is fairly simple to crash the PDO driver manager with