Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions ibm_db2.c
Original file line number Diff line number Diff line change
Expand Up @@ -4350,6 +4350,7 @@ static int _php_db2_bind_pad(param_node *curr, int nullterm, int isvarying, int

/* something went very wrong with heap */
if (Z_STRVAL_P(*data) == NULL ) {
php_error_docref(NULL, E_WARNING, "Pointer to string data for binding padding is null");
return SQL_ERROR;
}

Expand Down Expand Up @@ -4516,6 +4517,7 @@ static int _php_db2_bind_data( stmt_handle *stmt_res, param_node *curr, zval **b
break;

default:
php_error_docref(NULL, E_WARNING, "Unknown SQL data type %d used for binding", curr->data_type);
return SQL_ERROR;
}

Expand All @@ -4525,6 +4527,7 @@ static int _php_db2_bind_data( stmt_handle *stmt_res, param_node *curr, zval **b
if ( curr->param_type == DB2_PARAM_FILE) {
/* Only string types can be bound */
if ( ZEND_Z_TYPE_PP(bind_data) != IS_STRING) {
php_error_docref(NULL, E_WARNING, "Only string types can be bound, got %s", zend_zval_type_name(*bind_data));
return SQL_ERROR;
}
/* len = 0 */
Expand Down Expand Up @@ -4661,6 +4664,7 @@ static int _php_db2_bind_data( stmt_handle *stmt_res, param_node *curr, zval **b
break;

default:
php_error_docref(NULL, E_WARNING, "zval of type %s cannot be bound", zend_zval_type_name(curr->value));
return SQL_ERROR;
}
return rc;
Expand Down Expand Up @@ -4695,7 +4699,7 @@ static int _php_db2_execute_helper(stmt_handle *stmt_res, zval **data, int bind_
if (_php_db2_hash_find_ind(curr->varname, strlen(curr->varname), &temp, &bind_data, &symbol_table_used) != FAILURE ) {
rc = _php_db2_bind_data( stmt_res, curr, bind_data);
if ( rc == SQL_ERROR ) {
php_error_docref(NULL, E_WARNING, "Binding Error 1");
php_error_docref(NULL, E_WARNING, "Error binding $%s from cached parameters", curr->varname);
return rc;
}
curr = curr->next;
Expand Down Expand Up @@ -4729,7 +4733,7 @@ static int _php_db2_execute_helper(stmt_handle *stmt_res, zval **data, int bind_

rc = _php_db2_bind_data( stmt_res, curr, data);
if ( rc == SQL_ERROR ) {
php_error_docref(NULL, E_WARNING, "Binding Error 2");
php_error_docref(NULL, E_WARNING, "Error binding parameter number %d", param_no);
return rc;
}
} else {
Expand All @@ -4742,7 +4746,7 @@ static int _php_db2_execute_helper(stmt_handle *stmt_res, zval **data, int bind_
if ( curr != NULL ) {
rc = _php_db2_bind_data( stmt_res, curr, data);
if ( rc == SQL_ERROR ) {
php_error_docref(NULL, E_WARNING, "Binding Error 2");
php_error_docref(NULL, E_WARNING, "Error binding head cache node");
return rc;
}
stmt_res->current_node = curr->next;
Expand Down Expand Up @@ -4885,7 +4889,7 @@ PHP_FUNCTION(db2_execute)
*/
rc = _php_db2_execute_helper(stmt_res, data, 0, bind_params);
if ( rc == SQL_ERROR) {
php_error_docref(NULL, E_WARNING, "Binding Error");
php_error_docref(NULL, E_WARNING, "Error binding additional params in execute");
RETURN_FALSE;
}
/* Move array ptr forward */
Expand All @@ -4910,7 +4914,7 @@ PHP_FUNCTION(db2_execute)
/* And bind sequentially */
rc = _php_db2_execute_helper(stmt_res, NULL, 1, 0);
if ( rc == SQL_ERROR ) {
php_error_docref(NULL, E_WARNING, "Binding Error 3");
php_error_docref(NULL, E_WARNING, "Error binding params in execute");
RETURN_FALSE;
}
}
Expand Down Expand Up @@ -7847,7 +7851,7 @@ PHP_FUNCTION( db2_execute_many )
rc = SQLBindParameter(stmt_res->hstmt, curr->param_num, curr->param_type, valueType, curr->data_type, curr->param_size, curr->scale, (curr->value), 0, (SQLLEN *)&((curr->value)->value.lval));
}
if ( rc == SQL_ERROR ) {
sprintf(error, "Binding Error1 : %s", IBM_DB2_G(__php_stmt_err_msg));
sprintf(error, "Error binding params in execute many: %s", IBM_DB2_G(__php_stmt_err_msg));
_build_client_err_list(head_error_list, error);
err_count++;
break;
Expand Down
Loading