summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick van Kleef <iodbc@php.net>2008-09-01 15:48:09 +0000
committerPatrick van Kleef <iodbc@php.net>2008-09-01 15:48:09 +0000
commit331c423dbecd3af94aec302a1170e482fb35e3cc (patch)
treefa88b8e47a624a6ddc6fa00b70862b837c5321d0
parente624492e408b49cf2e8904ad135900d2dfe77413 (diff)
downloadphp-git-331c423dbecd3af94aec302a1170e482fb35e3cc.tar.gz
MFH: - Added odbc.default_cursortype to control the ODBC cursormodel
(bug #43668)
-rw-r--r--ext/odbc/php_odbc.c54
-rw-r--r--ext/odbc/php_odbc_includes.h1
2 files changed, 51 insertions, 4 deletions
diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c
index dbd848cbc2..78e5e81a64 100644
--- a/ext/odbc/php_odbc.c
+++ b/ext/odbc/php_odbc.c
@@ -380,6 +380,50 @@ static PHP_INI_DISP(display_lrl)
}
/* }}} */
+
+/* {{{ 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 @@ PHP_INI_BEGIN()
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()
/* }}} */
@@ -879,8 +925,8 @@ PHP_FUNCTION(odbc_prepare)
/* 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)
- == SQL_ERROR) {
+ 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);
efree(result);
@@ -1300,8 +1346,8 @@ PHP_FUNCTION(odbc_exec)
/* 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)
- == SQL_ERROR) {
+ 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);
efree(result);
diff --git a/ext/odbc/php_odbc_includes.h b/ext/odbc/php_odbc_includes.h
index 9add418cf1..fa487647f7 100644
--- a/ext/odbc/php_odbc_includes.h
+++ b/ext/odbc/php_odbc_includes.h
@@ -265,6 +265,7 @@ ZEND_BEGIN_MODULE_GLOBALS(odbc)
int defConn;
long defaultlrl;
long defaultbinmode;
+ long default_cursortype;
char laststate[6];
char lasterrormsg[SQL_MAX_MESSAGE_LENGTH];
HashTable *resource_list;