summaryrefslogtreecommitdiff
path: root/ext/pdo_odbc
diff options
context:
space:
mode:
authorWez Furlong <wez@php.net>2005-11-25 02:33:04 +0000
committerWez Furlong <wez@php.net>2005-11-25 02:33:04 +0000
commit268ac81e393708494731e249f2400866c3c394eb (patch)
tree4ead8c7a649d9c980ff04d86d69610cea0446d50 /ext/pdo_odbc
parent1d3f0d889123edd531fddd20ceb6ad71e3276b67 (diff)
downloadphp-git-268ac81e393708494731e249f2400866c3c394eb.tar.gz
Add pdo_odbc.db2_instance_name ini setting when built against DB2.
This is a convenience for setting up the DB2 environment more easily.
Diffstat (limited to 'ext/pdo_odbc')
-rwxr-xr-xext/pdo_odbc/pdo_odbc.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/ext/pdo_odbc/pdo_odbc.c b/ext/pdo_odbc/pdo_odbc.c
index b5bfc9c735..58b87be13a 100755
--- a/ext/pdo_odbc/pdo_odbc.c
+++ b/ext/pdo_odbc/pdo_odbc.c
@@ -74,6 +74,13 @@ SQLUINTEGER pdo_odbc_pool_on = SQL_CP_OFF;
SQLUINTEGER pdo_odbc_pool_mode = SQL_CP_ONE_PER_HENV;
#endif
+#if defined(DB2CLI_VER) && !defined(PHP_WIN32)
+PHP_INI_BEGIN()
+ PHP_INI_ENTRY("pdo_odbc.db2_instance_name", NULL, PHP_INI_SYSTEM, NULL)
+PHP_INI_END()
+
+#endif
+
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(pdo_odbc)
{
@@ -85,6 +92,20 @@ PHP_MINIT_FUNCTION(pdo_odbc)
return FAILURE;
}
+#if defined(DB2CLI_VER) && !defined(PHP_WIN32)
+ REGISTER_INI_ENTRIES();
+ {
+ char *instance = INI_STR("pdo_odbc.db2_instance_name");
+ if (instance) {
+ char *env = malloc(sizeof("DB2INSTANCE=") + strlen(instance));
+ strcpy(env, "DB2INSTANCE=");
+ strcat(env, instance);
+ putenv(env);
+ /* after this point, we can't free env without breaking the environment */
+ }
+ }
+#endif
+
#ifdef SQL_ATTR_CONNECTION_POOLING
/* ugh, we don't really like .ini stuff in PDO, but since ODBC connection
* pooling is process wide, we can't set it from within the scope of a
@@ -125,6 +146,9 @@ PHP_MINIT_FUNCTION(pdo_odbc)
*/
PHP_MSHUTDOWN_FUNCTION(pdo_odbc)
{
+#if defined(DB2CLI_VER) && !defined(PHP_WIN32)
+ UNREGISTER_INI_ENTRIES();
+#endif
php_pdo_unregister_driver(&pdo_odbc_driver);
return SUCCESS;
}
@@ -144,6 +168,9 @@ PHP_MINFO_FUNCTION(pdo_odbc)
#endif
php_info_print_table_end();
+#if defined(DB2CLI_VER) && !defined(PHP_WIN32)
+ DISPLAY_INI_ENTRIES();
+#endif
}
/* }}} */