@@ -108,6 +108,7 @@ typedef struct _conn_handle_struct {
108
108
long c_case_mode ;
109
109
long c_cursor_type ;
110
110
#ifdef PASE /* i5 override php.ini */
111
+ long c_i5_allow_commit ;
111
112
long c_i5_dbcs_alloc ;
112
113
long c_i5_sys_naming ;
113
114
char * c_i5_pending_cmd ;
@@ -184,7 +185,7 @@ typedef struct _stmt_handle_struct {
184
185
185
186
/* {{{ Every user visible function must have an entry in ibm_db2_functions[].
186
187
*/
187
- function_entry ibm_db2_functions [] = {
188
+ zend_function_entry ibm_db2_functions [] = {
188
189
PHP_FE (db2_connect , NULL )
189
190
PHP_FE (db2_commit , NULL )
190
191
PHP_FE (db2_pconnect , NULL )
@@ -1561,7 +1562,6 @@ static void _php_db2_assign_options( void *handle, int type, char *opt_key, zval
1561
1562
php_error_docref (NULL TSRMLS_CC , E_WARNING , "i5_fetch_only (DB2_I5_FETCH_ON , DB2_I5_FETCH_OFF )");
1562
1563
}
1563
1564
#endif /* PASE */
1564
- #ifndef PASE /* i5/OS not support yet */
1565
1565
} else if (!STRCASECMP (opt_key , "userid" )) {
1566
1566
rc = SQLSetConnectAttr ((SQLHDBC )((conn_handle * )handle )-> hdbc , SQL_ATTR_INFO_USERID , (SQLPOINTER )option_str , SQL_NTS );
1567
1567
if ( rc == SQL_ERROR ) {
@@ -1582,6 +1582,7 @@ static void _php_db2_assign_options( void *handle, int type, char *opt_key, zval
1582
1582
if ( rc == SQL_ERROR ) {
1583
1583
_php_db2_check_sql_errors ((SQLHSTMT )((conn_handle * )handle )-> hdbc , SQL_HANDLE_DBC , rc , 1 , NULL , -1 , 1 TSRMLS_CC );
1584
1584
}
1585
+ #ifndef PASE /* i5/OS not support yet */
1585
1586
} else if (!STRCASECMP (opt_key , "deferred_prepare" )) {
1586
1587
switch (option_num ) {
1587
1588
case DB2_DEFERRED_PREPARE_ON :
@@ -1979,8 +1980,10 @@ static void _php_db2_clear_stmt_err_cache(TSRMLS_D)
1979
1980
*/
1980
1981
static void _php_db2_clear_exec_many_err_cache ( stmt_handle * stmt )
1981
1982
{
1982
- efree (stmt -> exec_many_err_msg );
1983
- stmt -> exec_many_err_msg = NULL ;
1983
+ if ( stmt -> exec_many_err_msg != NULL ) {
1984
+ efree (stmt -> exec_many_err_msg );
1985
+ stmt -> exec_many_err_msg = NULL ;
1986
+ }
1984
1987
}
1985
1988
/* }}} */
1986
1989
@@ -2002,7 +2005,7 @@ static int _php_db2_connect_helper( INTERNAL_FUNCTION_PARAMETERS, conn_handle **
2002
2005
int reused = 0 ;
2003
2006
int hKeyLen = 0 ;
2004
2007
char * hKey = NULL ;
2005
- list_entry newEntry ;
2008
+ zend_rsrc_list_entry newEntry ;
2006
2009
char server [2048 ];
2007
2010
#ifdef PASE /* i5/OS incompatible v6 change */
2008
2011
long attr = SQL_TRUE ;
@@ -2040,7 +2043,7 @@ static int _php_db2_connect_helper( INTERNAL_FUNCTION_PARAMETERS, conn_handle **
2040
2043
do {
2041
2044
/* Check if we already have a connection for this userID & database combination */
2042
2045
if (isPersistent ) {
2043
- list_entry * entry ;
2046
+ zend_rsrc_list_entry * entry ;
2044
2047
hKeyLen = strlen (database ) + strlen (uid ) + strlen (password ) + 9 ;
2045
2048
hKey = (char * ) ecalloc (1 , hKeyLen );
2046
2049
@@ -2231,7 +2234,7 @@ static int _php_db2_connect_helper( INTERNAL_FUNCTION_PARAMETERS, conn_handle **
2231
2234
memset (& newEntry , 0 , sizeof (newEntry ));
2232
2235
Z_TYPE (newEntry ) = le_pconn_struct ;
2233
2236
newEntry .ptr = conn_res ;
2234
- if (zend_hash_update (& EG (persistent_list ), hKey , hKeyLen , (void * ) & newEntry , sizeof (list_entry ), NULL )== FAILURE ) {
2237
+ if (zend_hash_update (& EG (persistent_list ), hKey , hKeyLen , (void * ) & newEntry , sizeof (zend_rsrc_list_entry ), NULL )== FAILURE ) {
2235
2238
rc = SQL_ERROR ;
2236
2239
/* TBD: What error to return?, for now just generic SQL_ERROR */
2237
2240
}
@@ -3720,7 +3723,7 @@ static int _php_db2_bind_data( stmt_handle *stmt_res, param_node *curr, zval **b
3720
3723
if (curr -> param_type == DB2_PARAM_INOUT )
3721
3724
#endif
3722
3725
memset (Z_STRVAL_PP (bind_data )+ origlen ,0x20 , curr -> param_size - origlen );
3723
- if (nullterm ) Z_STRVAL_PP (bind_data )[curr -> param_size ] = '\0' ;
3726
+ if (nullterm ) Z_STRVAL_PP (bind_data )[origlen ] = '\0' ;
3724
3727
Z_STRLEN_PP (bind_data ) = curr -> param_size ;
3725
3728
}
3726
3729
#ifdef PASE /* help out PHP script trunc trailing chars -- LUW too? */
@@ -3910,7 +3913,8 @@ static int _php_db2_bind_data( stmt_handle *stmt_res, param_node *curr, zval **b
3910
3913
#endif /* PASE */
3911
3914
paramValuePtr = (SQLPOINTER )((curr -> value )-> value .str .val );
3912
3915
break ;
3913
- #ifdef PASE /* i5/OS should be SQL_NTS to avoid extra spaces */
3916
+ /*Not only PASE this applies to LUW too*/
3917
+ /*#ifdef PASE /* i5/OS should be SQL_NTS to avoid extra spaces */
3914
3918
case SQL_VARCHAR :
3915
3919
valueType = SQL_C_CHAR ;
3916
3920
curr -> bind_indicator = SQL_NTS ;
@@ -3921,7 +3925,7 @@ static int _php_db2_bind_data( stmt_handle *stmt_res, param_node *curr, zval **b
3921
3925
curr -> bind_indicator = SQL_NTS ; /* 20 */
3922
3926
paramValuePtr = (SQLPOINTER )((curr -> value )-> value .str .val );
3923
3927
break ;
3924
- #endif /* PASE */
3928
+ /* #endif /* PASE */
3925
3929
/* This option should handle most other types such as DATE, VARCHAR etc */
3926
3930
default :
3927
3931
valueType = SQL_C_CHAR ;
@@ -4310,6 +4314,13 @@ PHP_FUNCTION(db2_execute)
4310
4314
Z_STRLEN_P (tmp_curr -> value ) = strlen (Z_STRVAL_P (tmp_curr -> value ));
4311
4315
4312
4316
}
4317
+ else if (Z_TYPE_P ( tmp_curr -> value ) == IS_STRING
4318
+ && tmp_curr -> bind_indicator == SQL_NULL_DATA ) {
4319
+ if ((tmp_curr -> value )-> value .str .val != NULL || (tmp_curr -> value )-> value .str .len != 0 ) {
4320
+ efree ((tmp_curr -> value )-> value .str .val );
4321
+ }
4322
+ Z_TYPE_P (tmp_curr -> value ) = IS_NULL ;
4323
+ }
4313
4324
else if (Z_TYPE_P (tmp_curr -> value ) == IS_LONG || Z_TYPE_P (tmp_curr -> value ) == IS_BOOL ) {
4314
4325
/* bind in the value of long_value instead */
4315
4326
tmp_curr -> value -> value .lval = (long )tmp_curr -> long_value ;
@@ -4489,6 +4500,15 @@ PHP_FUNCTION(db2_next_result)
4489
4500
_php_db2_check_sql_errors (stmt_res -> hdbc , SQL_HANDLE_DBC , rc , 1 , NULL , -1 , 1 TSRMLS_CC );
4490
4501
RETURN_FALSE ;
4491
4502
}
4503
+ #ifdef PASEFORGETIT /* John Broich try SQLMoreResults (did not work though) */
4504
+ rc = SQLMoreResults ((SQLHSTMT )stmt_res -> hstmt );
4505
+ if ( rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO ) {
4506
+ return_value = stmt ;
4507
+ } else {
4508
+ _php_db2_check_sql_errors (stmt_res -> hstmt , SQL_HANDLE_STMT , rc , 1 , NULL , -1 , 1 TSRMLS_CC );
4509
+ RETURN_FALSE ;
4510
+ }
4511
+ #else /* LUW */
4492
4512
rc = SQLNextResult ((SQLHSTMT )stmt_res -> hstmt , (SQLHSTMT )new_hstmt );
4493
4513
if ( rc != SQL_SUCCESS ) {
4494
4514
if (rc < SQL_SUCCESS ) {
@@ -4518,6 +4538,7 @@ PHP_FUNCTION(db2_next_result)
4518
4538
new_stmt_res -> hdbc = stmt_res -> hdbc ;
4519
4539
4520
4540
ZEND_REGISTER_RESOURCE (return_value , new_stmt_res , le_stmt_struct );
4541
+ #endif /* PASE */
4521
4542
} else {
4522
4543
RETURN_FALSE ;
4523
4544
}
@@ -6758,6 +6779,9 @@ PHP_FUNCTION(db2_last_insert_id)
6758
6779
/* {{{ static int _ibm_db_chaining_flag(stmt_handle *stmt_res, SQLINTEGER flag, error_msg_node *error_list, int client_err_cnt TSRMLS_DC)
6759
6780
*/
6760
6781
static int _ibm_db_chaining_flag ( stmt_handle * stmt_res , SQLINTEGER flag , error_msg_node * error_list , int client_err_cnt TSRMLS_DC ) {
6782
+ #ifdef PASE /* i5/OS unsupported */
6783
+ return SQL_ERROR ;
6784
+ #else /* LUW */
6761
6785
int rc ;
6762
6786
rc = SQLSetStmtAttr ((SQLHSTMT )stmt_res -> hstmt , flag , (SQLPOINTER )SQL_TRUE , SQL_IS_INTEGER );
6763
6787
if ( flag == SQL_ATTR_CHAINING_BEGIN ) {
@@ -6793,6 +6817,7 @@ static int _ibm_db_chaining_flag( stmt_handle *stmt_res, SQLINTEGER flag, error_
6793
6817
}
6794
6818
}
6795
6819
return rc ;
6820
+ #endif /* i5/OS unsupported */
6796
6821
}
6797
6822
/* }}} */
6798
6823
@@ -6821,6 +6846,9 @@ static void _build_client_err_list( error_msg_node *head_error_list, char *err_m
6821
6846
execute a prepared statement */
6822
6847
PHP_FUNCTION ( db2_execute_many )
6823
6848
{
6849
+ #ifdef PASE /* i5/OS unsupported */
6850
+ RETURN_FALSE ;
6851
+ #else /* LUW */
6824
6852
int argc = ZEND_NUM_ARGS ();
6825
6853
int stmt_id = -1 ;
6826
6854
zval * stmt = NULL ;
@@ -6983,6 +7011,7 @@ PHP_FUNCTION( db2_execute_many )
6983
7011
RETURN_FALSE ;
6984
7012
}
6985
7013
RETURN_LONG (row_cnt );
7014
+ #endif /* i5/OS unsupported */
6986
7015
}
6987
7016
/* }}} */
6988
7017
0 commit comments