int blocks_initialized=1;
int i,j;
int *column_types;
+ RETCODE dbresults_retval;
switch(ZEND_NUM_ARGS()) {
case 1:
/*php_error_docref(NULL TSRMLS_CC, E_WARNING,"Sybase: Unable to set query");*/
RETURN_FALSE;
}
- if (dbsqlexec(sybase_ptr->link)==FAIL || dbresults(sybase_ptr->link)==FAIL) {
+
+ if (dbsqlexec(sybase_ptr->link)==FAIL) {
+ /*php_error(E_WARNING,"Sybase: Query failed");*/
+ RETURN_FALSE;
+ }
+
+ dbresults_retval = dbresults(sybase_ptr->link);
+ if (dbresults_retval==FAIL) {
/*php_error_docref(NULL TSRMLS_CC, E_WARNING,"Sybase: Query failed");*/
RETURN_FALSE;
}
efree(column_types);
Z_LVAL_P(return_value) = zend_list_insert(result,php_sybase_module.le_result);
Z_TYPE_P(return_value) = IS_LONG;
+
+ /**
+ * mgruetzner@rw3.com -- 3-6/2003
+ *
+ * If you do a query that calls a stored procedure which returns
+ * data AND calls raiserror to generated a user-defined error message,
+ * then after retrieving the first set of results above, the call
+ * to dbresults will have returned SUCCESS, instead of NO_MORE_RESULTS
+ * which indicates that the message generated by raiserror is still
+ * waiting to be read. If this is the case, then call dbresults
+ * again to force the reading of the message. This will ensure the
+ * get_last_message call will return the message properly if called
+ * after mssql_query, like it should.
+ *
+ * One thing to note, we are assuming that no more data should follow
+ * in this case--only the message will be read. To make sure, I have
+ * added a call to dbnextrow. The assumption is that it will return
+ * NO_MORE_ROWS in this case. If the assumption is false, generate
+ * a PHP error so we can debug this case.
+ *
+ */
+ if (dbresults_retval != NO_MORE_RESULTS) {
+ /* Call dbresults again to read message */
+ dbresults_retval = dbresults(sybase_ptr->link);
+
+ /* Check assumption that dbnextrow returns NO_MORE_ROWS */
+ retvalue = dbnextrow(sybase_ptr->link);
+ if (retvalue != NO_MORE_ROWS) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,"Expected dbnextrow() to return NO_MORE_ROWS.");
+ }
+ }
}
/* }}} */