22
22
$Id$
23
23
*/
24
24
25
-
26
25
#ifdef HAVE_CONFIG_H
27
26
#include "config.h"
28
27
#endif
@@ -98,7 +97,6 @@ typedef struct _conn_handle_struct {
98
97
SQLHANDLE henv ;
99
98
SQLHANDLE hdbc ;
100
99
long auto_commit ;
101
- long is_auto_commit ;
102
100
long c_bin_mode ;
103
101
long c_case_mode ;
104
102
long c_cursor_type ;
@@ -168,6 +166,7 @@ typedef struct _stmt_handle_struct {
168
166
db2_row_type * row_data ;
169
167
} stmt_handle ;
170
168
169
+
171
170
/* equivalent functions on different platforms */
172
171
#ifdef PHP_WIN32
173
172
#define STRCASECMP stricmp
@@ -1136,7 +1135,6 @@ static void _php_db2_assign_options( void *handle, int type, char *opt_key, zval
1136
1135
}
1137
1136
} else if (!STRCASECMP (opt_key , "autocommit" )) {
1138
1137
if (type == SQL_HANDLE_DBC ) {
1139
- ((conn_handle * )handle )-> is_auto_commit = 1 ;
1140
1138
switch (option_num ) {
1141
1139
case DB2_AUTOCOMMIT_ON :
1142
1140
/* Setting AUTOCOMMIT again here. The user could modify
@@ -2078,6 +2076,19 @@ static int _php_db2_connect_helper( INTERNAL_FUNCTION_PARAMETERS, conn_handle **
2078
2076
}
2079
2077
}
2080
2078
2079
+ conn_res -> auto_commit = SQL_AUTOCOMMIT_ON ;
2080
+ #ifndef PASE
2081
+ rc = SQLSetConnectAttr ((SQLHDBC )conn_res -> hdbc , SQL_ATTR_AUTOCOMMIT , (SQLPOINTER )(conn_res -> auto_commit ), SQL_NTS );
2082
+ #else /* PASE */
2083
+ rc = SQLSetConnectAttr ((SQLHDBC )conn_res -> hdbc , SQL_ATTR_AUTOCOMMIT , (SQLPOINTER )(& conn_res -> auto_commit ), SQL_NTS );
2084
+ conn_res -> c_i5_allow_commit = IBM_DB2_G (i5_allow_commit );
2085
+ conn_res -> c_i5_dbcs_alloc = IBM_DB2_G (i5_dbcs_alloc );
2086
+ if (IBM_DB2_G (i5_job_sort )) {
2087
+ attr = 2 ; /* 2 = special value John Broich PTF */
2088
+ rc = SQLSetConnectAttr ((SQLHDBC )conn_res -> hdbc , 10046 , (SQLPOINTER )& attr , 0 );
2089
+ }
2090
+ #endif /* PASE */
2091
+
2081
2092
conn_res -> c_bin_mode = IBM_DB2_G (bin_mode );
2082
2093
conn_res -> c_case_mode = DB2_CASE_NATURAL ;
2083
2094
conn_res -> c_cursor_type = DB2_FORWARD_ONLY ;
@@ -2088,13 +2099,8 @@ static int _php_db2_connect_helper( INTERNAL_FUNCTION_PARAMETERS, conn_handle **
2088
2099
/* handle not active as of yet */
2089
2100
conn_res -> handle_active = 0 ;
2090
2101
conn_res -> flag_transaction = 0 ;
2091
-
2092
- #ifdef PASE /* i5/OS php.ini unique settings */
2093
- conn_res -> c_i5_pending_cmd = NULL ;
2094
- conn_res -> c_i5_dbcs_alloc = IBM_DB2_G (i5_dbcs_alloc );
2095
- /* i5/OS OFF default and tests fail (LUW is ON default) */
2096
- conn_res -> auto_commit = SQL_AUTOCOMMIT_ON ;
2097
- rc = SQLSetConnectAttr ((SQLHDBC )conn_res -> hdbc , SQL_ATTR_AUTOCOMMIT , (SQLPOINTER )(& conn_res -> auto_commit ), SQL_NTS );
2102
+ #ifdef PASE
2103
+ conn_res -> c_i5_pending_cmd = NULL ;
2098
2104
#endif /* PASE */
2099
2105
/* Set Options */
2100
2106
if ( options != NULL ) {
@@ -2103,6 +2109,15 @@ static int _php_db2_connect_helper( INTERNAL_FUNCTION_PARAMETERS, conn_handle **
2103
2109
php_error_docref (NULL TSRMLS_CC , E_WARNING , "Options Array must have string indexes" );
2104
2110
}
2105
2111
}
2112
+ #ifdef PASE
2113
+ if (!conn_res -> c_i5_allow_commit ) {
2114
+ if (!rc ) {
2115
+ SQLINTEGER nocommitpase = SQL_TXN_NO_COMMIT ;
2116
+ SQLSetConnectOption ((SQLHDBC )conn_res -> hdbc , SQL_ATTR_COMMIT , (SQLPOINTER )& nocommitpase );
2117
+ }
2118
+ }
2119
+ #endif /* PASE */
2120
+
2106
2121
if (! reused ) {
2107
2122
/* Connect */
2108
2123
/* If the string contains a =, use SQLDriverConnect */
@@ -2164,28 +2179,6 @@ static int _php_db2_connect_helper( INTERNAL_FUNCTION_PARAMETERS, conn_handle **
2164
2179
#endif /* PASE */
2165
2180
}
2166
2181
2167
- /* Set this after the connection handle has been allocated to avoid
2168
- unnecessary network flows. Initialize the structure to default values */
2169
- if (conn_res -> is_auto_commit ) {
2170
- #ifndef PASE /* i5/OS needs ptr to value */
2171
- rc = SQLSetConnectAttr ((SQLHDBC )conn_res -> hdbc , SQL_ATTR_AUTOCOMMIT , (SQLPOINTER )(conn_res -> auto_commit ), SQL_NTS );
2172
- #else /* PASE */
2173
- rc = SQLSetConnectAttr ((SQLHDBC )conn_res -> hdbc , SQL_ATTR_AUTOCOMMIT , (SQLPOINTER )(& conn_res -> auto_commit ), SQL_NTS );
2174
- #endif /* PASE */
2175
- }
2176
- #ifdef PASE /* i5/OS php.ini unique override settings */
2177
- /* i5/OS 2 = special value John Broich PTF */
2178
- if (IBM_DB2_G (i5_job_sort )) {
2179
- attr = 2 ;
2180
- SQLSetConnectAttr ((SQLHDBC )conn_res -> hdbc , 10046 , (SQLPOINTER )& attr , 0 );
2181
- }
2182
- /* i5/OS CRTLIB style schemas do not allow commit */
2183
- if (!IBM_DB2_G (i5_allow_commit )) {
2184
- SQLINTEGER nocommitpase = SQL_TXN_NO_COMMIT ;
2185
- SQLSetConnectOption ((SQLHDBC )conn_res -> hdbc , SQL_ATTR_COMMIT , (SQLPOINTER )& nocommitpase );
2186
- }
2187
- #endif /* PASE */
2188
-
2189
2182
conn_res -> handle_active = 1 ;
2190
2183
} while (0 );
2191
2184
@@ -2791,9 +2784,7 @@ PHP_FUNCTION(db2_columns)
2791
2784
zval * connection = NULL ;
2792
2785
conn_handle * conn_res ;
2793
2786
stmt_handle * stmt_res ;
2794
- stmt_handle * stmt_res_identity ;
2795
2787
int rc ;
2796
- int i ;
2797
2788
2798
2789
if (zend_parse_parameters (argc TSRMLS_CC , "r|ssss" , & connection , & qualifier ,
2799
2790
& qualifier_len , & owner , & owner_len , & table_name , & table_name_len ,
@@ -3178,7 +3169,8 @@ PHP_FUNCTION(db2_statistics)
3178
3169
}
3179
3170
3180
3171
if (connection ) {
3181
- ZEND_FETCH_RESOURCE (conn_res , conn_handle * , & connection , connection_id , "Connection Resource" , le_conn_struct );
3172
+ ZEND_FETCH_RESOURCE2 (conn_res , conn_handle * , & connection , connection_id ,
3173
+ "Connection Resource" , le_conn_struct , le_pconn_struct );
3182
3174
3183
3175
stmt_res = _db2_new_stmt_struct (conn_res );
3184
3176
sql_unique = unique ;
@@ -3387,7 +3379,6 @@ PHP_FUNCTION(db2_commit)
3387
3379
static int _php_db2_do_prepare (SQLHANDLE hdbc , char * stmt_string , stmt_handle * stmt_res , int stmt_string_len , zval * options TSRMLS_DC )
3388
3380
{
3389
3381
int rc ;
3390
- SQLINTEGER vParam ;
3391
3382
3392
3383
/* alloc handle and return only if it errors */
3393
3384
rc = SQLAllocHandle (SQL_HANDLE_STMT , hdbc , & (stmt_res -> hstmt ));
@@ -3440,7 +3431,6 @@ PHP_FUNCTION(db2_exec)
3440
3431
stmt_handle * stmt_res ;
3441
3432
conn_handle * conn_res ;
3442
3433
int rc ;
3443
- SQLINTEGER vParam ;
3444
3434
3445
3435
/* This function basically is a wrap of the _php_db2_do_prepare and _php_db2_execute_stmt */
3446
3436
/* After completing statement execution, it returns the statement resource */
@@ -3534,6 +3524,7 @@ PHP_FUNCTION(db2_prepare)
3534
3524
& stmt_string_len , & options ) == FAILURE ) {
3535
3525
return ;
3536
3526
}
3527
+
3537
3528
if (connection ) {
3538
3529
ZEND_FETCH_RESOURCE2 (conn_res , conn_handle * , & connection , connection_id ,
3539
3530
"Connection Resource" , le_conn_struct , le_pconn_struct );
@@ -3886,6 +3877,7 @@ static int _php_db2_bind_data( stmt_handle *stmt_res, param_node *curr, zval **b
3886
3877
curr -> bind_indicator = (curr -> value )-> value .str .len ;
3887
3878
paramValuePtr = (SQLPOINTER )((curr -> value )-> value .str .val );
3888
3879
}
3880
+
3889
3881
rc = SQLBindParameter (stmt_res -> hstmt , curr -> param_num ,
3890
3882
curr -> param_type , valueType , curr -> data_type , curr -> param_size ,
3891
3883
curr -> scale , paramValuePtr , Z_STRLEN_P (curr -> value )+ 1 , & (curr -> bind_indicator ));
0 commit comments