Index: ext/odbc/php_odbc.c
===================================================================
RCS file: /repository/php-src/ext/odbc/php_odbc.c,v
retrieving revision 1.189.2.4.2.7.2.3
diff -u -r1.189.2.4.2.7.2.3 php_odbc.c
--- ext/odbc/php_odbc.c	31 Dec 2007 07:17:11 -0000	1.189.2.4.2.7.2.3
+++ ext/odbc/php_odbc.c	7 Jan 2008 14:12:20 -0000
@@ -64,7 +64,7 @@
 
 static int le_result, le_conn, le_pconn;
 
-#define SAFE_SQL_NTS(n) ((SWORD) ((n)?(SQL_NTS):0))
+#define SAFE_SQL_NTS(n) ((SQLSMALLINT) ((n)?(SQL_NTS):0))
 
 /* {{{ odbc_functions[]
  */
@@ -180,7 +180,7 @@
 		if (res->stmt) {
 #if defined(HAVE_SOLID) || defined(HAVE_SOLID_30) || defined(HAVE_SOLID_35)
 			SQLTransact(res->conn_ptr->henv, res->conn_ptr->hdbc,
-						(UWORD)SQL_COMMIT);
+						(SQLUSMALLINT) SQL_COMMIT);
 #endif
 			rc = SQLFreeStmt(res->stmt,SQL_DROP);
 			/* We don't want the connection to be closed after the last statment has been closed
@@ -380,6 +380,50 @@
 }
 /* }}} */
 
+
+/* {{{ PHP_INI_DISP(display_cursortype)
+ */
+static PHP_INI_DISP(display_cursortype)
+{
+	char *value;
+	TSRMLS_FETCH();
+
+	if (type == PHP_INI_DISPLAY_ORIG && ini_entry->modified) {
+		value = ini_entry->orig_value;
+	} else if (ini_entry->value) {
+		value = ini_entry->value;
+	} else {
+		value = NULL;
+	}
+
+	if (value) {
+		switch (atoi (value))
+		  {
+		    case SQL_CURSOR_FORWARD_ONLY:
+				PUTS ("Forward Only cursor");
+				break;
+
+			case SQL_CURSOR_STATIC:
+			    PUTS ("Static cursor");
+				break;
+
+			case SQL_CURSOR_KEYSET_DRIVEN:
+				PUTS ("Keyset driven cursor");
+				break;
+
+			case SQL_CURSOR_DYNAMIC:
+				PUTS ("Dynamic cursor");
+				break;
+
+			default:
+				php_printf("Unknown cursor model %s", value);
+				break;
+		  }
+	}
+}
+
+/* }}} */
+
 /* {{{ PHP_INI_BEGIN 
  */
 PHP_INI_BEGIN()
@@ -401,6 +445,8 @@
 			defaultbinmode, zend_odbc_globals, odbc_globals, display_binmode)
 	STD_PHP_INI_BOOLEAN("odbc.check_persistent", "1", PHP_INI_SYSTEM, OnUpdateLong,
 			check_persistent, zend_odbc_globals, odbc_globals)
+	STD_PHP_INI_ENTRY_EX("odbc.default_cursortype", "3", PHP_INI_ALL, OnUpdateLong, 
+			default_cursortype, zend_odbc_globals, odbc_globals, display_cursortype)
 PHP_INI_END()
 /* }}} */
 
@@ -565,9 +611,9 @@
 void odbc_sql_error(ODBC_SQL_ERROR_PARAMS)
 {
 	char	state[6];
-	SDWORD	error;        /* Not used */
+	SQLINTEGER	error;        /* Not used */
 	char	errormsg[SQL_MAX_MESSAGE_LENGTH];
-	SWORD	errormsgsize; /* Not used */
+	SQLSMALLINT	errormsgsize; /* Not used */
 	RETCODE rc;
 	ODBC_SQL_ENV_T henv;
 	ODBC_SQL_CONN_T conn;
@@ -641,8 +687,8 @@
 {
 	RETCODE rc;
 	int i;
-	SWORD       colnamelen; /* Not used */
-	SDWORD      displaysize;
+	SQLSMALLINT       colnamelen; /* Not used */
+	SQLLEN      displaysize;
 
 	result->values = (odbc_result_value *) safe_emalloc(sizeof(odbc_result_value), result->numcols, 0);
 
@@ -650,9 +696,9 @@
 	result->binmode = ODBCG(defaultbinmode);
 
 	for(i = 0; i < result->numcols; i++) {
-		rc = SQLColAttributes(result->stmt, (UWORD)(i+1), SQL_COLUMN_NAME, 
+		rc = SQLColAttributes(result->stmt, (SQLUSMALLINT)(i+1), SQL_COLUMN_NAME, 
 				result->values[i].name, sizeof(result->values[i].name), &colnamelen, 0);
-		rc = SQLColAttributes(result->stmt, (UWORD)(i+1), SQL_COLUMN_TYPE, 
+		rc = SQLColAttributes(result->stmt, (SQLUSMALLINT)(i+1), SQL_COLUMN_TYPE, 
 				NULL, 0, NULL, &result->values[i].coltype);
 		
 		/* Don't bind LONG / BINARY columns, so that fetch behaviour can
@@ -670,17 +716,17 @@
 #ifdef HAVE_ADABAS
 			case SQL_TIMESTAMP:
 				result->values[i].value = (char *)emalloc(27);
-				SQLBindCol(result->stmt, (UWORD)(i+1), SQL_C_CHAR, result->values[i].value,
+				SQLBindCol(result->stmt, (SQLUSMALLINT)(i+1), SQL_C_CHAR, result->values[i].value,
 							27, &result->values[i].vallen);
 				break;
 #endif /* HAVE_ADABAS */
 			default:
-				rc = SQLColAttributes(result->stmt, (UWORD)(i+1), SQL_COLUMN_DISPLAY_SIZE,
+				rc = SQLColAttributes(result->stmt, (SQLUSMALLINT)(i+1), SQL_COLUMN_DISPLAY_SIZE,
 									NULL, 0, NULL, &displaysize);
 				displaysize = displaysize <= result->longreadlen ? displaysize : 
 								result->longreadlen;
 				result->values[i].value = (char *)emalloc(displaysize + 1);
-				rc = SQLBindCol(result->stmt, (UWORD)(i+1), SQL_C_CHAR, result->values[i].value,
+				rc = SQLBindCol(result->stmt, (SQLUSMALLINT)(i+1), SQL_C_CHAR, result->values[i].value,
 							displaysize + 1, &result->values[i].vallen);
 				break;
 		}
@@ -702,7 +748,7 @@
 
 	ZEND_FETCH_RESOURCE2(conn, odbc_connection *, pv_conn, -1, "ODBC-Link", le_conn, le_pconn);
 	
-	rc = SQLTransact(conn->henv, conn->hdbc, (UWORD)((type)?SQL_COMMIT:SQL_ROLLBACK));
+	rc = SQLTransact(conn->henv, conn->hdbc, (SQLUSMALLINT)((type)?SQL_COMMIT:SQL_ROLLBACK));
 	if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
 		odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLTransact");
 		RETURN_FALSE;
@@ -727,7 +773,7 @@
 void odbc_column_lengths(INTERNAL_FUNCTION_PARAMETERS, int type)
 {
 	odbc_result *result;
-#if defined(HAVE_SOLID) || defined(HAVE_SOLID_30) || defined(HAVE_OPENLINK)
+#if defined(HAVE_SOLID) || defined(HAVE_SOLID_30)
 	/* this seems to be necessary for Solid2.3 ( tested by 
 	 * tammy@synchronis.com) and Solid 3.0 (tested by eric@terra.telemediair.nl)
 	 * Solid does not seem to declare a SQLINTEGER, but it does declare a
@@ -736,7 +782,7 @@
 	 */
 	SDWORD len;
 #else
-	SQLINTEGER len;
+	SQLLEN len;
 #endif
 	zval **pv_res, **pv_num;
 
@@ -763,7 +809,7 @@
 		RETURN_FALSE;
 	}
 
-	SQLColAttributes(result->stmt, (UWORD)Z_LVAL_PP(pv_num), 
+	SQLColAttributes(result->stmt, (SQLUSMALLINT)Z_LVAL_PP(pv_num), 
 					(SQLUSMALLINT) (type?SQL_COLUMN_SCALE:SQL_COLUMN_PRECISION),
 					NULL, 0, NULL, &len);
 
@@ -841,7 +887,7 @@
 	odbc_connection *conn;
 	RETCODE rc;
 #ifdef HAVE_SQL_EXTENDED_FETCH
-	UDWORD      scrollopts;
+	SQLUINTEGER      scrollopts;
 #endif
 
 	if (zend_get_parameters_ex(2, &pv_conn, &pv_query) == FAILURE) {
@@ -879,7 +925,8 @@
 			/* Try to set CURSOR_TYPE to dynamic. Driver will replace this with other
 			   type if not possible.
 			*/
-			if (SQLSetStmtOption(result->stmt, SQL_CURSOR_TYPE, SQL_CURSOR_DYNAMIC)
+			int cursortype = ODBCG(default_cursortype);
+			if (SQLSetStmtOption(result->stmt, SQL_CURSOR_TYPE, cursortype)
 				== SQL_ERROR) {
 				odbc_sql_error(conn, result->stmt, " SQLSetStmtOption");
 				SQLFreeStmt(result->stmt, SQL_DROP);
@@ -932,15 +979,15 @@
 { 
 	zval **pv_res, **pv_param_arr, **tmp;
 	typedef struct params_t {
-		SDWORD vallen;
+		SQLLEN vallen;
 		int fp;
 	} params_t;
 	params_t *params = NULL;
 	char *filename;
 	unsigned char otype;
-   	SWORD sqltype, ctype, scale;
-	SWORD nullable;
-	UDWORD precision;
+   	SQLSMALLINT sqltype, ctype, scale;
+	SQLSMALLINT nullable;
+	SQLULEN precision;
    	odbc_result   *result;
 	int numArgs, i, ne;
 	RETCODE rc;
@@ -997,7 +1044,7 @@
 				RETURN_FALSE;
 			}
 			
-			SQLDescribeParam(result->stmt, (UWORD)i, &sqltype, &precision,
+			SQLDescribeParam(result->stmt, (SQLUSMALLINT)i, &sqltype, &precision,
 							 &scale, &nullable);
 			params[i-1].vallen = Z_STRLEN_PP(tmp);
 			params[i-1].fp = -1;
@@ -1044,7 +1091,7 @@
 
 				params[i-1].vallen = SQL_LEN_DATA_AT_EXEC(0);
 
-				rc = SQLBindParameter(result->stmt, (UWORD)i, SQL_PARAM_INPUT,
+				rc = SQLBindParameter(result->stmt, (SQLUSMALLINT)i, SQL_PARAM_INPUT,
 									  ctype, sqltype, precision, scale,
 									  (void *)params[i-1].fp, 0,
 									  &params[i-1].vallen);
@@ -1056,7 +1103,7 @@
 					params[i-1].vallen = SQL_NULL_DATA;
 				}
 
-				rc = SQLBindParameter(result->stmt, (UWORD)i, SQL_PARAM_INPUT,
+				rc = SQLBindParameter(result->stmt, (SQLUSMALLINT)i, SQL_PARAM_INPUT,
 									  ctype, sqltype, precision, scale,
 									  Z_STRVAL_PP(tmp), 0,
 									  &params[i-1].vallen);
@@ -1131,7 +1178,8 @@
 PHP_FUNCTION(odbc_cursor)
 {
 	zval **pv_res;
-	SWORD len, max_len;
+	SQLUSMALLINT max_len;
+	SQLSMALLINT len;
 	char *cursorname;
    	odbc_result *result;
 	RETCODE rc;
@@ -1150,12 +1198,12 @@
 	
 	if (max_len > 0) {
 		cursorname = emalloc(max_len + 1);
-		rc = SQLGetCursorName(result->stmt,cursorname,(SWORD)max_len,&len);
+		rc = SQLGetCursorName(result->stmt,cursorname,(SQLSMALLINT)max_len,&len);
 		if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
 			char    state[6];     /* Not used */
-	 		SDWORD  error;        /* Not used */
-			char    errormsg[255];
-			SWORD   errormsgsize; /* Not used */
+	 		SQLINTEGER  error;        /* Not used */
+			char    errormsg[SQL_MAX_MESSAGE_LENGTH];
+			SQLSMALLINT   errormsgsize; /* Not used */
 
 			SQLError( result->conn_ptr->henv, result->conn_ptr->hdbc,
 						result->stmt, state, &error, errormsg,
@@ -1257,7 +1305,7 @@
 	odbc_connection *conn;
 	RETCODE rc;
 #ifdef HAVE_SQL_EXTENDED_FETCH
-	UDWORD      scrollopts;
+	SQLUINTEGER      scrollopts;
 #endif
 
 	numArgs = ZEND_NUM_ARGS();
@@ -1299,7 +1347,8 @@
 			/* Try to set CURSOR_TYPE to dynamic. Driver will replace this with other
 			   type if not possible.
 			 */
-			if (SQLSetStmtOption(result->stmt, SQL_CURSOR_TYPE, SQL_CURSOR_DYNAMIC)
+			int cursortype = ODBCG(default_cursortype);
+			if (SQLSetStmtOption(result->stmt, SQL_CURSOR_TYPE, cursortype)
 				== SQL_ERROR) {
 				odbc_sql_error(conn, result->stmt, " SQLSetStmtOption");
 				SQLFreeStmt(result->stmt, SQL_DROP);
@@ -1351,12 +1400,12 @@
 	int i;
 	odbc_result *result;
 	RETCODE rc;
-	SWORD sql_c_type;
+	SQLSMALLINT sql_c_type;
 	char *buf = NULL;
 #ifdef HAVE_SQL_EXTENDED_FETCH
-	UDWORD crow;
-	UWORD  RowStatus[1];
-	SDWORD rownum = -1;
+	SQLULEN crow;
+	SQLUSMALLINT  RowStatus[1];
+	SQLLEN rownum = -1;
 	zval **pv_res, **pv_row, *tmp;
 
 	switch(ZEND_NUM_ARGS()) {
@@ -1435,7 +1484,7 @@
 					break;
 				}
 				if (buf == NULL) buf = emalloc(result->longreadlen + 1);
-				rc = SQLGetData(result->stmt, (UWORD)(i + 1), sql_c_type,
+				rc = SQLGetData(result->stmt, (SQLUSMALLINT)(i + 1), sql_c_type,
 						buf, result->longreadlen + 1, &result->values[i].vallen);
 
 				if (rc == SQL_ERROR) {
@@ -1509,14 +1558,14 @@
 	int numArgs, i;
 	odbc_result *result;
 	RETCODE rc;
-	SWORD sql_c_type;
+	SQLSMALLINT sql_c_type;
 	char *buf = NULL;
 	zval **pv_res, **pv_res_arr, *tmp;
 #ifdef HAVE_SQL_EXTENDED_FETCH
 	zval **pv_row;
-	UDWORD crow;
-	UWORD  RowStatus[1];
-	SDWORD rownum = -1;
+	SQLULEN crow;
+	SQLUSMALLINT  RowStatus[1];
+	SQLLEN rownum = -1;
 #endif /* HAVE_SQL_EXTENDED_FETCH */
 	
 	numArgs = ZEND_NUM_ARGS();
@@ -1594,7 +1643,7 @@
 				}
 
 				if (buf == NULL) buf = emalloc(result->longreadlen + 1);
-				rc = SQLGetData(result->stmt, (UWORD)(i + 1),sql_c_type,
+				rc = SQLGetData(result->stmt, (SQLUSMALLINT)(i + 1),sql_c_type,
 								buf, result->longreadlen + 1, &result->values[i].vallen);
 
 					if (rc == SQL_ERROR) {
@@ -1665,13 +1714,13 @@
 PHP_FUNCTION(odbc_fetch_row)
 {
 	int numArgs;
-	SDWORD rownum = 1;
+	SQLLEN rownum = 1;
 	odbc_result *result;
 	RETCODE rc;
 	zval **pv_res, **pv_row;
 #ifdef HAVE_SQL_EXTENDED_FETCH
-	UDWORD crow;
-	UWORD RowStatus[1];
+	SQLULEN crow;
+	SQLUSMALLINT RowStatus[1];
 #endif
 
 	numArgs = ZEND_NUM_ARGS();
@@ -1727,15 +1776,15 @@
 {
 	char *field;
 	int field_ind;
-	SWORD sql_c_type = SQL_C_CHAR;
+	SQLSMALLINT sql_c_type = SQL_C_CHAR;
 	odbc_result *result;
 	int i = 0;
 	RETCODE rc;
-	SDWORD	fieldsize;
+	SQLLEN	fieldsize;
 	zval **pv_res, **pv_field;
 #ifdef HAVE_SQL_EXTENDED_FETCH
-	UDWORD crow;
-	UWORD RowStatus[1];
+	SQLULEN crow;
+	SQLUSMALLINT RowStatus[1];
 #endif
 
 	field_ind = -1;
@@ -1813,8 +1862,8 @@
 			   else 
 				   fieldsize = result->longreadlen;
 			} else {
-			   SQLColAttributes(result->stmt, (UWORD)(field_ind + 1), 
-					   			(UWORD)((sql_c_type == SQL_C_BINARY) ? SQL_COLUMN_LENGTH :
+			   SQLColAttributes(result->stmt, (SQLUSMALLINT)(field_ind + 1), 
+					   			(SQLUSMALLINT)((sql_c_type == SQL_C_BINARY) ? SQL_COLUMN_LENGTH :
 					   			SQL_COLUMN_DISPLAY_SIZE),
 					   			NULL, 0, NULL, &fieldsize);
 			}
@@ -1825,7 +1874,7 @@
 		/* SQLGetData will truncate CHAR data to fieldsize - 1 bytes and append \0.
 		 * For binary data it is truncated to fieldsize bytes. 
 		 */
-			rc = SQLGetData(result->stmt, (UWORD)(field_ind + 1), sql_c_type,
+			rc = SQLGetData(result->stmt, (SQLUSMALLINT)(field_ind + 1), sql_c_type,
 							field, fieldsize, &result->values[field_ind].vallen);
 
 			if (rc == SQL_ERROR) {
@@ -1868,7 +1917,7 @@
 	
 	/* Call SQLGetData() until SQL_SUCCESS is returned */
 	while(1) {
-		rc = SQLGetData(result->stmt, (UWORD)(field_ind + 1),sql_c_type,
+		rc = SQLGetData(result->stmt, (SQLUSMALLINT)(field_ind + 1),sql_c_type,
 							field, fieldsize, &result->values[field_ind].vallen);
 
 		if (rc == SQL_ERROR) {
@@ -1903,10 +1952,10 @@
 	odbc_result *result;
 	RETCODE rc;
 	zval **pv_res, **pv_format;
-	SWORD sql_c_type;
+	SQLSMALLINT sql_c_type;
 #ifdef HAVE_SQL_EXTENDED_FETCH
-	UDWORD crow;
-	UWORD RowStatus[1];
+	SQLULEN crow;
+	SQLUSMALLINT RowStatus[1];
 #endif
 
 	numArgs = ZEND_NUM_ARGS();
@@ -1972,7 +2021,7 @@
 
 					if (buf == NULL) buf = emalloc(result->longreadlen);
 
-					rc = SQLGetData(result->stmt, (UWORD)(i + 1),sql_c_type,
+					rc = SQLGetData(result->stmt, (SQLUSMALLINT)(i + 1),sql_c_type,
 								buf, result->longreadlen, &result->values[i].vallen);
  
 					php_printf("<td>");
@@ -2138,7 +2187,7 @@
 	}
 /*  Possible fix for bug #10250
  *  Needs testing on UnixODBC < 2.0.5 though. */
-#if defined(HAVE_EMPRESS) || defined(HAVE_UNIXODBC) || defined(PHP_WIN32)
+#if defined(HAVE_EMPRESS) || defined(HAVE_UNIXODBC) || defined(PHP_WIN32) || defined (HAVE_IODBC)
 /* *  Uncomment the line above, and comment line below to fully test 
  * #ifdef HAVE_EMPRESS */
 	{
@@ -2314,7 +2363,7 @@
 			if(ODBCG(check_persistent)){
 				RETCODE ret;
 				UCHAR d_name[32];
-				SWORD len;
+				SQLSMALLINT len;
 
 				ret = SQLGetInfo(db_conn->hdbc, 
 					SQL_DATA_SOURCE_READ_ONLY, 
@@ -2430,7 +2479,7 @@
 PHP_FUNCTION(odbc_num_rows)
 {
 	odbc_result *result;
-	SDWORD rows;
+	SQLLEN rows;
 	zval **pv_res;
 	
 	if (zend_get_parameters_ex(1, &pv_res) == FAILURE) {
@@ -2546,7 +2595,7 @@
 {
 	odbc_result	*result;
 	char    	tmp[32];
-	SWORD   	tmplen;
+	SQLSMALLINT   	tmplen;
 	zval     **pv_res, **pv_num;
 
 	if (zend_get_parameters_ex(2, &pv_res, &pv_num) == FAILURE) {
@@ -2572,7 +2621,7 @@
 		RETURN_FALSE;
 	}
 
-	SQLColAttributes(result->stmt, (UWORD)Z_LVAL_PP(pv_num),
+	SQLColAttributes(result->stmt, (SQLUSMALLINT)Z_LVAL_PP(pv_num),
 					 SQL_COLUMN_TYPE_NAME, tmp, 31, &tmplen, NULL);
 	RETURN_STRING(tmp,1)
 }
@@ -2666,7 +2715,7 @@
 		}
 		RETVAL_TRUE;
 	} else {
-		SDWORD status;
+		SQLINTEGER status;
 
 		rc = SQLGetConnectOption(conn->hdbc, SQL_AUTOCOMMIT, (PTR)&status);
 		if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
@@ -2897,7 +2946,7 @@
 	odbc_result   *result = NULL;
 	odbc_connection *conn;
 	char *cat = NULL, *schema = NULL, *table = NULL, *column = NULL;
-	SWORD cat_len=0, schema_len=0, table_len=0, column_len=0;
+	SQLSMALLINT cat_len=0, schema_len=0, table_len=0, column_len=0;
 	RETCODE rc;
 	int argc;
 
@@ -3156,7 +3205,7 @@
 	odbc_connection *conn;
 	RETCODE rc;
 	int argc;
-	SWORD data_type = SQL_ALL_TYPES;
+	SQLSMALLINT data_type = SQL_ALL_TYPES;
 
 	argc = ZEND_NUM_ARGS();
 	if (argc == 1) {
@@ -3168,7 +3217,7 @@
 			WRONG_PARAM_COUNT;
 		}
 		convert_to_long_ex(pv_data_type);
-		data_type = (SWORD) Z_LVAL_PP(pv_data_type);
+		data_type = (SQLSMALLINT) Z_LVAL_PP(pv_data_type);
 	} else {
 		WRONG_PARAM_COUNT;
 	}
@@ -3452,8 +3501,8 @@
 	odbc_result   *result = NULL;
 	odbc_connection *conn;
 	char *cat = NULL, *schema = NULL, *name = NULL;
-	UWORD type;
-	UWORD scope, nullable;
+	SQLUSMALLINT type;
+	SQLUSMALLINT scope, nullable;
 	RETCODE rc;
 	int argc;
 
@@ -3464,7 +3513,7 @@
 			WRONG_PARAM_COUNT;
 		}
 		convert_to_long_ex(pv_type);
-		type = (UWORD) Z_LVAL_PP(pv_type);
+		type = (SQLUSMALLINT) Z_LVAL_PP(pv_type);
 		convert_to_string_ex(pv_cat);
 		cat = Z_STRVAL_PP(pv_cat);
 		convert_to_string_ex(pv_schema);
@@ -3472,9 +3521,9 @@
 		convert_to_string_ex(pv_name);
 		name = Z_STRVAL_PP(pv_name);
 		convert_to_long_ex(pv_scope);
-		scope = (UWORD) Z_LVAL_PP(pv_scope);
+		scope = (SQLUSMALLINT) Z_LVAL_PP(pv_scope);
 		convert_to_long_ex(pv_nullable);
-		nullable = (UWORD) Z_LVAL_PP(pv_nullable);
+		nullable = (SQLUSMALLINT) Z_LVAL_PP(pv_nullable);
 	} else {
 		WRONG_PARAM_COUNT;
 	}
@@ -3536,7 +3585,7 @@
 	odbc_result   *result = NULL;
 	odbc_connection *conn;
 	char *cat = NULL, *schema = NULL, *name = NULL;
-	UWORD unique, reserved;
+	SQLUSMALLINT unique, reserved;
 	RETCODE rc;
 	int argc;
 
@@ -3553,9 +3602,9 @@
 		convert_to_string_ex(pv_name);
 		name = Z_STRVAL_PP(pv_name);
 		convert_to_long_ex(pv_unique);
-		unique = (UWORD) Z_LVAL_PP(pv_unique);
+		unique = (SQLUSMALLINT) Z_LVAL_PP(pv_unique);
 		convert_to_long_ex(pv_reserved);
-		reserved = (UWORD) Z_LVAL_PP(pv_reserved);
+		reserved = (SQLUSMALLINT) Z_LVAL_PP(pv_reserved);
 	} else {
 		WRONG_PARAM_COUNT;
 	}
Index: ext/odbc/php_odbc.h
===================================================================
RCS file: /repository/php-src/ext/odbc/php_odbc.h,v
retrieving revision 1.60.2.1.2.1.2.1
diff -u -r1.60.2.1.2.1.2.1 php_odbc.h
--- ext/odbc/php_odbc.h	31 Dec 2007 07:17:11 -0000	1.60.2.1.2.1.2.1
+++ ext/odbc/php_odbc.h	7 Jan 2008 14:12:20 -0000
@@ -33,7 +33,7 @@
 extern zend_module_entry odbc_module_entry;
 #define odbc_module_ptr &odbc_module_entry
 
-#if defined(HAVE_DBMAKER) || defined(PHP_WIN32) || defined(HAVE_IBMDB2) || defined(HAVE_UNIXODBC) || defined(HAVE_BIRDSTEP)
+#if defined(HAVE_DBMAKER) || defined(PHP_WIN32) || defined(HAVE_IBMDB2) || defined(HAVE_UNIXODBC) || defined(HAVE_BIRDSTEP) || defined(HAVE_IODBC)
 # define PHP_ODBC_HAVE_FETCH_HASH 1
 #endif
 
Index: ext/odbc/php_odbc_includes.h
===================================================================
RCS file: /repository/php-src/ext/odbc/php_odbc_includes.h,v
retrieving revision 1.12.2.1.2.4.2.1
diff -u -r1.12.2.1.2.4.2.1 php_odbc_includes.h
--- ext/odbc/php_odbc_includes.h	31 Dec 2007 07:17:11 -0000	1.12.2.1.2.4.2.1
+++ ext/odbc/php_odbc_includes.h	7 Jan 2008 14:12:20 -0000
@@ -90,19 +90,19 @@
 
 #elif defined(HAVE_IODBC) /* iODBC library */
 
+#ifdef CHAR
+#undef CHAR
+#endif
+
+#ifdef SQLCHAR
+#undef SQLCHAR
+#endif
+
 #define ODBC_TYPE "iODBC"
-#include <isql.h>
-#include <isqlext.h>
+#include <sql.h>
+#include <sqlext.h>
+#include <iodbcext.h>
 #define HAVE_SQL_EXTENDED_FETCH 1
-#define SQL_FD_FETCH_ABSOLUTE   0x00000010L
-#define SQL_CURSOR_DYNAMIC      2UL
-#define SQL_NO_TOTAL            (-4)
-#define SQL_SO_DYNAMIC          0x00000004L
-#define SQL_LEN_DATA_AT_EXEC_OFFSET  (-100)
-#define SQL_LEN_DATA_AT_EXEC(length) (-(length)+SQL_LEN_DATA_AT_EXEC_OFFSET)
-#ifndef SQL_SUCCEEDED
-#define SQL_SUCCEEDED(rc) (((rc)&(~1))==0)
-#endif
 
 #elif defined(HAVE_UNIXODBC) /* unixODBC library */
 
@@ -148,8 +148,12 @@
 #include <isqlext.h>
 #include <udbcext.h>
 #define HAVE_SQL_EXTENDED_FETCH 1
+#ifndef SQLSMALLINT
 #define SQLSMALLINT SWORD
+#endif
+#ifndef SQLUSMALLINT
 #define SQLUSMALLINT UWORD
+#endif
 
 #elif defined(HAVE_BIRDSTEP) /* Raima Birdstep */
 
@@ -204,7 +208,7 @@
 
 /* Common defines */
 
-#if defined( HAVE_IBMDB2 ) || defined( HAVE_UNIXODBC )
+#if defined( HAVE_IBMDB2 ) || defined( HAVE_UNIXODBC ) || defined (HAVE_IODBC)
 #define ODBC_SQL_ENV_T SQLHANDLE
 #define ODBC_SQL_CONN_T SQLHANDLE
 #define ODBC_SQL_STMT_T SQLHANDLE
@@ -230,15 +234,15 @@
 typedef struct odbc_result_value {
 	char name[32];
 	char *value;
-	SDWORD vallen;
-	SDWORD coltype;
+	SQLLEN vallen;
+	SQLLEN coltype;
 } odbc_result_value;
 
 typedef struct odbc_result {
 	ODBC_SQL_STMT_T stmt;
 	odbc_result_value *values;
-	SWORD numcols;
-	SWORD numparams;
+	SQLSMALLINT numcols;
+	SQLSMALLINT numparams;
 # if HAVE_SQL_EXTENDED_FETCH
 	int fetch_abs;
 # endif
@@ -261,6 +265,7 @@
 	int defConn;
     long defaultlrl;
     long defaultbinmode;
+    long default_cursortype;
     char laststate[6];
     char lasterrormsg[SQL_MAX_MESSAGE_LENGTH];
 	HashTable *resource_list;
