]> granicus.if.org Git - php/commitdiff
Add flag to control the use of the ODBC cursor emulation library.
authorWez Furlong <wez@php.net>
Tue, 25 May 2004 17:44:36 +0000 (17:44 +0000)
committerWez Furlong <wez@php.net>
Tue, 25 May 2004 17:44:36 +0000 (17:44 +0000)
The default (which should be safe) is to use the cursor library if it is needed.
If for some reason either the driver or the emulation is broken, you may
override this from your script.

ext/pdo_odbc/odbc_driver.c
ext/pdo_odbc/pdo_odbc.c
ext/pdo_odbc/php_pdo_odbc_int.h

index 23660bc7937fc46f28dbb5bcc784d134fb1a1b77..ccbaf470e1fc841879e8cb7a0fc849d21ec47662 100755 (executable)
@@ -287,6 +287,7 @@ static int pdo_odbc_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_D
        pdo_odbc_db_handle *H;
        RETCODE rc;
        int use_direct = 0;
+       SQLUINTEGER cursor_lib;
 
        H = pecalloc(1, sizeof(*H), dbh->is_persistent);
 
@@ -327,6 +328,15 @@ static int pdo_odbc_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_D
                        return 0;
                }
        }
+
+       /* set up the cursor library, if needed, or if configured explicitly */
+       cursor_lib = pdo_attr_lval(driver_options, PDO_ODBC_ATTR_USE_CURSOR_LIBRARY, SQL_CUR_USE_IF_NEEDED TSRMLS_CC);
+       rc = SQLSetConnectAttr(H->dbc, SQL_ODBC_CURSORS, (void*)cursor_lib, SQL_IS_UINTEGER);
+       if (rc != SQL_SUCCESS) {
+               pdo_odbc_drv_error("SQLSetConnectAttr SQL_ODBC_CURSORS");
+               odbc_handle_closer(dbh TSRMLS_CC);
+               return 0;
+       }
        
        if (strchr(dbh->data_source, ';')) {
                char dsnbuf[1024];
index 09c18cd2a312c8521d7b250182e2fb956e8aff80..e8dc26b5aee53c3380bbfaacf493512bc4df08ba 100755 (executable)
@@ -109,6 +109,11 @@ PHP_MINIT_FUNCTION(pdo_odbc)
        }
 #endif
 
+       REGISTER_LONG_CONSTANT("PDO_ODBC_ATTR_USE_CURSOR_LIBRARY", PDO_ODBC_ATTR_USE_CURSOR_LIBRARY, CONST_CS|CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("PDO_ODBC_SQL_USE_IF_NEEDED", SQL_CUR_USE_IF_NEEDED, CONST_CS|CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("PDO_ODBC_SQL_USE_DRIVER", SQL_CUR_USE_DRIVER, CONST_CS|CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("PDO_ODBC_SQL_USE_ODBC", SQL_CUR_USE_ODBC, CONST_CS|CONST_PERSISTENT);
+       
        return SUCCESS;
 }
 /* }}} */
index 424b3dbdca2e14ef9b47a0ed1e7e48690ece6108..e249be56872f94f7a56565bb118b41394edd4851 100755 (executable)
@@ -149,6 +149,10 @@ extern SQLUINTEGER pdo_odbc_pool_on;
 extern SQLUINTEGER pdo_odbc_pool_mode;
 #endif
 
+enum {
+       PDO_ODBC_ATTR_USE_CURSOR_LIBRARY = PDO_ATTR_DRIVER_SPECIFIC,
+};
+
 /*
  * Local variables:
  * tab-width: 4