sniper Fri Jan 31 09:21:19 2003 EDT
Modified files: (Branch: PHP_4_3)
/php4/ext/oci8 CREDITS config.m4 oci8.c php_oci8.h
Log:
MFH all changes as requested by Maxim.
Index: php4/ext/oci8/CREDITS
diff -u php4/ext/oci8/CREDITS:1.3 php4/ext/oci8/CREDITS:1.3.12.1
--- php4/ext/oci8/CREDITS:1.3 Sat Apr 14 04:38:46 2001
+++ php4/ext/oci8/CREDITS Fri Jan 31 09:21:19 2003
@@ -1,2 +1,2 @@
OCI8
-Stig Bakken, Thies C. Arntzen, Andy Sautins, David Benson
+Stig Bakken, Thies C. Arntzen, Andy Sautins, David Benson, Maxim Maletsky
Index: php4/ext/oci8/config.m4
diff -u php4/ext/oci8/config.m4:1.37.2.1 php4/ext/oci8/config.m4:1.37.2.2
--- php4/ext/oci8/config.m4:1.37.2.1 Fri Jan 24 12:51:40 2003
+++ php4/ext/oci8/config.m4 Fri Jan 31 09:21:19 2003
@@ -1,5 +1,5 @@
dnl
-dnl $Id: config.m4,v 1.37.2.1 2003/01/24 17:51:40 sniper Exp $
+dnl $Id: config.m4,v 1.37.2.2 2003/01/31 14:21:19 sniper Exp $
dnl
AC_DEFUN(PHP_OCI_IF_DEFINED,[
@@ -86,18 +86,31 @@
PHP_ADD_LIBRARY_WITH_PATH(clntsh, $OCI8_DIR/lib, OCI8_SHARED_LIBADD)
;;
- 8.1|9.0)
+ 8.1)
PHP_ADD_LIBRARY(clntsh, 1, OCI8_SHARED_LIBADD)
if test -f $OCI8_DIR/lib/libocijdbc8.so ; then
PHP_ADD_LIBRARY(ocijdbc8, 1, OCI8_SHARED_LIBADD)
fi
PHP_ADD_LIBPATH($OCI8_DIR/lib, OCI8_SHARED_LIBADD)
+ AC_DEFINE(HAVE_OCI8_TEMP_LOB,1,[ ])
+ AC_DEFINE(HAVE_OCI8_SHARED_MODE,1,[ ])
dnl
- dnl OCI_ATTR_STATEMENT is not always available
+ dnl OCI_ATTR_STATEMENT is not available in all 8.1.x versions
dnl
PHP_OCI_IF_DEFINED(OCI_ATTR_STATEMENT, [AC_DEFINE(HAVE_OCI8_ATTR_STATEMENT,1,[
])], $OCI8_INCLUDES)
+ ;;
+
+ 9.0)
+ PHP_ADD_LIBRARY(clntsh, 1, OCI8_SHARED_LIBADD)
+ if test -f $OCI8_DIR/lib/libocijdbc8.so ; then
+ PHP_ADD_LIBRARY(ocijdbc8, 1, OCI8_SHARED_LIBADD)
+ fi
+ PHP_ADD_LIBPATH($OCI8_DIR/lib, OCI8_SHARED_LIBADD)
AC_DEFINE(HAVE_OCI8_TEMP_LOB,1,[ ])
+ AC_DEFINE(HAVE_OCI8_ATTR_STATEMENT,1,[ ])
+ AC_DEFINE(HAVE_OCI8_SHARED_MODE,1,[ ])
+ AC_DEFINE(HAVE_OCI9,1,[ ])
;;
*)
Index: php4/ext/oci8/oci8.c
diff -u php4/ext/oci8/oci8.c:1.183.2.1 php4/ext/oci8/oci8.c:1.183.2.2
--- php4/ext/oci8/oci8.c:1.183.2.1 Tue Dec 31 11:35:03 2002
+++ php4/ext/oci8/oci8.c Fri Jan 31 09:21:19 2003
@@ -14,13 +14,14 @@
+----------------------------------------------------------------------+
| Authors: Stig S�ther Bakken <[EMAIL PROTECTED]> |
| Thies C. Arntzen <[EMAIL PROTECTED]> |
+ | Maxim Maletsky <[EMAIL PROTECTED]> |
| |
| Collection support by Andy Sautins <[EMAIL PROTECTED]> |
| Temporary LOB support by David Benson <[EMAIL PROTECTED]> |
+----------------------------------------------------------------------+
*/
-/* $Id: oci8.c,v 1.183.2.1 2002/12/31 16:35:03 sebastian Exp $ */
+/* $Id: oci8.c,v 1.183.2.2 2003/01/31 14:21:19 sniper Exp $ */
/* TODO list:
*
@@ -28,7 +29,6 @@
* especialliy important for things like oci_ping
* - Change return-value for OCIFetch*() (1-row read, 0-Normal end, false-error)
* - Error mode (print or shut up?)
- * - OCIPasswordChange()
* - binding of arrays
* - Character sets for NCLOBS
* - split the module into an upper (php-callable) and lower (c-callable) layer!
@@ -48,7 +48,7 @@
* - delay OCIInitialize() as far as we can.
* - add PHP Array <-> OCICollection conversion
* - add Collection iterator object for INDEX BY tables
- * - make auto-rollabck only happen if we have an outstanding transaction
+ * - make auto-rollback only happen if we have an outstanding transaction
* - implement ocidisconnect
*/
@@ -69,14 +69,14 @@
#include "php_oci8.h"
/* True globals, no need for thread safety */
-static int le_conn;
-static int le_stmt;
-static int le_desc;
+static int le_conn;
+static int le_stmt;
+static int le_desc;
#ifdef WITH_COLLECTIONS
-static int le_coll;
+static int le_coll;
#endif
-static int le_server;
-static int le_session;
+static int le_server;
+static int le_session;
static zend_class_entry *oci_lob_class_entry_ptr;
#ifdef WITH_COLLECTIONS
static zend_class_entry *oci_coll_class_entry_ptr;
@@ -102,7 +102,7 @@
#define CALL_OCI(call) \
{ \
if (OCI(in_call)) { \
- php_error(E_WARNING, "OCI8 Recursive call!\n"); \
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "OCI8 Recursive call!\n");
+\
exit(-1); \
} else { \
OCI(in_call)=1; \
@@ -115,7 +115,7 @@
{ \
if (OCI(in_call)) { \
retcode=-1; \
- php_error(E_WARNING, "OCI8 Recursive call!\n"); \
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "OCI8 Recursive call!\n");
+\
exit(-1); \
} else { \
OCI(in_call)=1; \
@@ -195,7 +195,7 @@
static oci_server *_oci_open_server(char *dbname,int persistent);
static void _oci_close_server(oci_server *server);
-static oci_session *_oci_open_session(oci_server* server,char *username,char
*password,int persistent,int exclusive);
+static oci_session *_oci_open_session(oci_server* server,char *username,char
+*password,int persistent,int exclusive, char *charset);
static void _oci_close_session(oci_session *session);
static sb4 oci_bind_in_callback(dvoid *, OCIBind *, ub4, ub4, dvoid **, ub4 *, ub1 *,
dvoid **);
@@ -245,6 +245,7 @@
PHP_FUNCTION(ocistatementtype);
PHP_FUNCTION(ocirowcount);
PHP_FUNCTION(ocisetprefetch);
+PHP_FUNCTION(ocipasswordchange);
#ifdef HAVE_OCI8_TEMP_LOB
PHP_FUNCTION(ociwritetemporarylob);
PHP_FUNCTION(ocicloselob);
@@ -281,122 +282,123 @@
#ifdef WITH_COLLECTIONS
#define OCI_GET_COLL(collection,index) \
- collection = oci_get_coll(index TSRMLS_CC); \
- if (collection == NULL) { \
- RETURN_FALSE; \
- }
+ collection = oci_get_coll(index TSRMLS_CC); \
+ if (collection == NULL) { \
+ RETURN_FALSE; \
+ }
#endif
/* }}} */
/* {{{ extension definition structures */
-#define OCI_ASSOC 1<<0
-#define OCI_NUM 1<<1
-#define OCI_BOTH (OCI_ASSOC|OCI_NUM)
-
-#define OCI_RETURN_NULLS 1<<2
-#define OCI_RETURN_LOBS 1<<3
-
-#define OCI_FETCHSTATEMENT_BY_COLUMN 1<<4
-#define OCI_FETCHSTATEMENT_BY_ROW 1<<5
-#define OCI_FETCHSTATEMENT_BY (OCI_FETCHSTATEMENT_BY_COLUMN |
OCI_FETCHSTATEMENT_BY_ROW)
+#define OCI_ASSOC 1<<0
+#define OCI_NUM 1<<1
+#define OCI_BOTH (OCI_ASSOC|OCI_NUM)
+
+#define OCI_RETURN_NULLS 1<<2
+#define OCI_RETURN_LOBS 1<<3
+
+#define OCI_FETCHSTATEMENT_BY_COLUMN 1<<4
+#define OCI_FETCHSTATEMENT_BY_ROW 1<<5
+#define OCI_FETCHSTATEMENT_BY (OCI_FETCHSTATEMENT_BY_COLUMN |
+OCI_FETCHSTATEMENT_BY_ROW)
static unsigned char a3_arg_force_ref[] = { 3, BYREF_NONE, BYREF_NONE, BYREF_FORCE };
static unsigned char a2_arg_force_ref[] = { 2, BYREF_NONE, BYREF_FORCE };
static zend_function_entry php_oci_functions[] = {
- PHP_FE(ocidefinebyname, a3_arg_force_ref)
- PHP_FE(ocibindbyname, a3_arg_force_ref)
- PHP_FE(ocicolumnisnull, NULL)
- PHP_FE(ocicolumnname, NULL)
- PHP_FE(ocicolumnsize, NULL)
- PHP_FE(ocicolumnscale, NULL)
- PHP_FE(ocicolumnprecision, NULL)
- PHP_FE(ocicolumntype, NULL)
- PHP_FE(ocicolumntyperaw, NULL)
- PHP_FE(ociexecute, NULL)
- PHP_FE(ocicancel, NULL)
- PHP_FE(ocifetch, NULL)
- PHP_FE(ocifetchinto, a2_arg_force_ref)
- PHP_FE(ocifetchstatement,a2_arg_force_ref)
- PHP_FE(ocifreestatement, NULL)
- PHP_FE(ociinternaldebug, NULL)
- PHP_FE(ocinumcols, NULL)
- PHP_FE(ociparse, NULL)
- PHP_FE(ocinewcursor, NULL)
- PHP_FE(ociresult, NULL)
- PHP_FE(ociserverversion, NULL)
- PHP_FE(ocistatementtype, NULL)
- PHP_FE(ocirowcount, NULL)
- PHP_FE(ocilogoff, NULL)
- PHP_FE(ocilogon, NULL)
- PHP_FE(ocinlogon, NULL)
- PHP_FE(ociplogon, NULL)
- PHP_FE(ocierror, NULL)
- PHP_FE(ocifreedesc, NULL)
- PHP_FE(ocisavelob, NULL)
- PHP_FE(ocisavelobfile, NULL)
- PHP_FE(ociloadlob, NULL)
- PHP_FE(ociwritelobtofile,NULL)
- PHP_FE(ocicommit, NULL)
- PHP_FE(ocirollback, NULL)
- PHP_FE(ocinewdescriptor, NULL)
- PHP_FE(ocisetprefetch, NULL)
+ PHP_FE(ocidefinebyname, a3_arg_force_ref)
+ PHP_FE(ocibindbyname, a3_arg_force_ref)
+ PHP_FE(ocicolumnisnull, NULL)
+ PHP_FE(ocicolumnname, NULL)
+ PHP_FE(ocicolumnsize, NULL)
+ PHP_FE(ocicolumnscale, NULL)
+ PHP_FE(ocicolumnprecision, NULL)
+ PHP_FE(ocicolumntype, NULL)
+ PHP_FE(ocicolumntyperaw, NULL)
+ PHP_FE(ociexecute, NULL)
+ PHP_FE(ocicancel, NULL)
+ PHP_FE(ocifetch, NULL)
+ PHP_FE(ocifetchinto, a2_arg_force_ref)
+ PHP_FE(ocifetchstatement, a2_arg_force_ref)
+ PHP_FE(ocifreestatement, NULL)
+ PHP_FE(ociinternaldebug, NULL)
+ PHP_FE(ocinumcols, NULL)
+ PHP_FE(ociparse, NULL)
+ PHP_FE(ocinewcursor, NULL)
+ PHP_FE(ociresult, NULL)
+ PHP_FE(ociserverversion, NULL)
+ PHP_FE(ocistatementtype, NULL)
+ PHP_FE(ocirowcount, NULL)
+ PHP_FE(ocilogoff, NULL)
+ PHP_FE(ocilogon, NULL)
+ PHP_FE(ocinlogon, NULL)
+ PHP_FE(ociplogon, NULL)
+ PHP_FE(ocierror, NULL)
+ PHP_FE(ocifreedesc, NULL)
+ PHP_FE(ocisavelob, NULL)
+ PHP_FE(ocisavelobfile, NULL)
+ PHP_FE(ociloadlob, NULL)
+ PHP_FE(ociwritelobtofile, NULL)
+ PHP_FE(ocicommit, NULL)
+ PHP_FE(ocirollback, NULL)
+ PHP_FE(ocinewdescriptor, NULL)
+ PHP_FE(ocisetprefetch, NULL)
+ PHP_FE(ocipasswordchange, NULL)
#ifdef WITH_COLLECTIONS
- PHP_FE(ocifreecollection,NULL)
- PHP_FE(ocicollappend, NULL)
- PHP_FE(ocicollgetelem, NULL)
- PHP_FE(ocicollassignelem,NULL)
- PHP_FE(ocicollassign, NULL)
- PHP_FE(ocicollsize, NULL)
- PHP_FE(ocicollmax, NULL)
- PHP_FE(ocicolltrim, NULL)
- PHP_FE(ocinewcollection, NULL)
+ PHP_FE(ocifreecollection, NULL)
+ PHP_FE(ocicollappend, NULL)
+ PHP_FE(ocicollgetelem, NULL)
+ PHP_FE(ocicollassignelem, NULL)
+ PHP_FE(ocicollassign, NULL)
+ PHP_FE(ocicollsize, NULL)
+ PHP_FE(ocicollmax, NULL)
+ PHP_FE(ocicolltrim, NULL)
+ PHP_FE(ocinewcollection, NULL)
#endif
- PHP_FALIAS(ocifreecursor,ocifreestatement,NULL)
+ PHP_FALIAS(ocifreecursor,ocifreestatement,NULL)
- {NULL,NULL,NULL}
+ {NULL,NULL,NULL}
};
static zend_function_entry php_oci_lob_class_functions[] = {
- PHP_FALIAS(load, ociloadlob, NULL)
- PHP_FALIAS(writetofile, ociwritelobtofile,NULL)
+ PHP_FALIAS(load, ociloadlob, NULL)
+ PHP_FALIAS(writetofile, ociwritelobtofile, NULL)
#ifdef HAVE_OCI8_TEMP_LOB
- PHP_FALIAS(writetemporary, ociwritetemporarylob,NULL)
- PHP_FALIAS(close, ocicloselob, NULL)
+ PHP_FALIAS(writetemporary, ociwritetemporarylob,NULL)
+ PHP_FALIAS(close, ocicloselob, NULL)
#endif
- PHP_FALIAS(save, ocisavelob, NULL)
- PHP_FALIAS(savefile, ocisavelobfile, NULL)
- PHP_FALIAS(free, ocifreedesc, NULL)
- {NULL,NULL,NULL}
+ PHP_FALIAS(save, ocisavelob, NULL)
+ PHP_FALIAS(savefile, ocisavelobfile, NULL)
+ PHP_FALIAS(free, ocifreedesc, NULL)
+ {NULL,NULL,NULL}
};
#ifdef WITH_COLLECTIONS
static zend_function_entry php_oci_coll_class_functions[] = {
- PHP_FALIAS(append, ocicollappend, NULL)
- PHP_FALIAS(getelem, ocicollgetelem, NULL)
- PHP_FALIAS(assignelem, ocicollassignelem, NULL)
- PHP_FALIAS(assign, ocicollassign, NULL)
- PHP_FALIAS(size, ocicollsize, NULL)
- PHP_FALIAS(max, ocicollmax, NULL)
- PHP_FALIAS(trim, ocicolltrim, NULL)
- PHP_FALIAS(free, ocifreecollection, NULL)
- {NULL,NULL,NULL}
+ PHP_FALIAS(append, ocicollappend, NULL)
+ PHP_FALIAS(getelem, ocicollgetelem, NULL)
+ PHP_FALIAS(assignelem, ocicollassignelem, NULL)
+ PHP_FALIAS(assign, ocicollassign, NULL)
+ PHP_FALIAS(size, ocicollsize, NULL)
+ PHP_FALIAS(max, ocicollmax, NULL)
+ PHP_FALIAS(trim, ocicolltrim, NULL)
+ PHP_FALIAS(free, ocifreecollection, NULL)
+ {NULL,NULL,NULL}
};
#endif
zend_module_entry oci8_module_entry = {
STANDARD_MODULE_HEADER,
- "oci8", /* extension name */
- php_oci_functions, /* extension function list */
- PHP_MINIT(oci), /* extension-wide startup function */
- PHP_MSHUTDOWN(oci), /* extension-wide shutdown function */
- PHP_RINIT(oci), /* per-request startup function */
- PHP_RSHUTDOWN(oci), /* per-request shutdown function */
- PHP_MINFO(oci), /* information function */
- NO_VERSION_YET,
- STANDARD_MODULE_PROPERTIES
+ "oci8", /* extension name */
+ php_oci_functions, /* extension function list */
+ PHP_MINIT(oci), /* extension-wide startup function */
+ PHP_MSHUTDOWN(oci), /* extension-wide shutdown function */
+ PHP_RINIT(oci), /* per-request startup function */
+ PHP_RSHUTDOWN(oci), /* per-request shutdown function */
+ PHP_MINFO(oci), /* information function */
+ NO_VERSION_YET,
+ STANDARD_MODULE_PROPERTIES
};
/* }}} */
@@ -407,24 +409,24 @@
#if OCI_USE_EMALLOC
CONST dvoid *ocimalloc(dvoid *ctx, size_t size)
{
- dvoid *ret;
+ dvoid *ret;
ret = (dvoid *)malloc(size);
- oci_debug("ocimalloc(%d) = %08x", size,ret);
- return ret;
+ oci_debug("ocimalloc(%d) = %08x", size,ret);
+ return ret;
}
CONST dvoid *ocirealloc(dvoid *ctx, dvoid *ptr, size_t size)
{
- dvoid *ret;
- oci_debug("ocirealloc(%08x, %d)", ptr, size);
+ dvoid *ret;
+ oci_debug("ocirealloc(%08x, %d)", ptr, size);
ret = (dvoid *)realloc(ptr, size);
- return ptr;
+ return ptr;
}
CONST void ocifree(dvoid *ctx, dvoid *ptr)
{
- oci_debug("ocifree(%08x)", ptr);
- free(ptr);
+ oci_debug("ocifree(%08x)", ptr);
+ free(ptr);
}
#endif
@@ -460,15 +462,27 @@
{
zend_class_entry oci_lob_class_entry;
#ifdef WITH_COLLECTIONS
- zend_class_entry oci_coll_class_entry;
+ zend_class_entry oci_coll_class_entry;
#endif
+#ifdef HAVE_OCI8_SHARED_MODE
+
+#ifdef WITH_COLLECTIONS
+#define PHP_OCI_INIT_MODE OCI_SHARED | OCI_OBJECT
+#else
+#define PHP_OCI_INIT_MODE OCI_SHARED
+#endif
+
+#else
+
#ifdef WITH_COLLECTIONS
#define PHP_OCI_INIT_MODE OCI_DEFAULT | OCI_OBJECT
#else
#define PHP_OCI_INIT_MODE OCI_DEFAULT
#endif
+#endif
+
#if OCI_USE_EMALLOC
OCIInitialize(PHP_OCI_INIT_MODE, NULL, ocimalloc, ocirealloc, ocifree);
#else
@@ -485,19 +499,19 @@
le_conn = zend_register_list_destructors_ex(php_oci_free_conn_list, NULL,
"oci8 connection", module_number);
le_desc = zend_register_list_destructors_ex(_oci_descriptor_list_dtor, NULL,
"oci8 descriptor", module_number);
#ifdef WITH_COLLECTIONS
- le_coll = zend_register_list_destructors_ex(_oci_coll_list_dtor, NULL, "oci8
collection", module_number);
+ le_coll = zend_register_list_destructors_ex(_oci_coll_list_dtor, NULL, "oci8
+collection", module_number);
#endif
le_server = zend_register_list_destructors_ex(_oci_server_list_dtor, NULL,
"oci8 server", module_number);
le_session = zend_register_list_destructors_ex(_oci_session_list_dtor, NULL,
"oci8 session", module_number);
INIT_CLASS_ENTRY(oci_lob_class_entry, "OCI-Lob", php_oci_lob_class_functions);
#ifdef WITH_COLLECTIONS
- INIT_CLASS_ENTRY(oci_coll_class_entry, "OCI-Collection",
php_oci_coll_class_functions);
+ INIT_CLASS_ENTRY(oci_coll_class_entry, "OCI-Collection",
+php_oci_coll_class_functions);
#endif
- oci_lob_class_entry_ptr = zend_register_internal_class(&oci_lob_class_entry
TSRMLS_CC);
+ oci_lob_class_entry_ptr = zend_register_internal_class(&oci_lob_class_entry
+TSRMLS_CC);
#ifdef WITH_COLLECTIONS
- oci_coll_class_entry_ptr = zend_register_internal_class(&oci_coll_class_entry
TSRMLS_CC);
+ oci_coll_class_entry_ptr = zend_register_internal_class(&oci_coll_class_entry
+TSRMLS_CC);
#endif
/* [EMAIL PROTECTED] 990203 i do not think that we will need all of them - just in
here for completeness for now! */
@@ -514,8 +528,8 @@
REGISTER_LONG_CONSTANT("SQLT_RDD",SQLT_RDD, CONST_CS | CONST_PERSISTENT);
#ifdef WITH_COLLECTIONS
- REGISTER_LONG_CONSTANT("OCI_B_SQLT_NTY",SQLT_NTY, CONST_CS | CONST_PERSISTENT);
- REGISTER_STRING_CONSTANT("OCI_SYSDATE","SYSDATE",CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("OCI_B_SQLT_NTY",SQLT_NTY, CONST_CS | CONST_PERSISTENT);
+ REGISTER_STRING_CONSTANT("OCI_SYSDATE","SYSDATE",CONST_PERSISTENT);
#endif
REGISTER_LONG_CONSTANT("OCI_B_BFILE",SQLT_BFILEE, CONST_CS | CONST_PERSISTENT);
@@ -562,9 +576,9 @@
OCI(debug_mode) = 0; /* start "fresh" */
/* OCI(in_call) = 0; i don't think we want this! */
- oci_debug("php_rinit_oci");
+ oci_debug("php_rinit_oci");
- return SUCCESS;
+ return SUCCESS;
}
static int _session_pcleanup(oci_session *session TSRMLS_DC)
@@ -585,7 +599,7 @@
{
OCI(shutdown) = 1;
- oci_debug("START php_mshutdown_oci");
+ oci_debug("START php_mshutdown_oci");
zend_hash_apply(OCI(user), (apply_func_t)_session_pcleanup TSRMLS_CC);
zend_hash_apply(OCI(server), (apply_func_t)_server_pcleanup TSRMLS_CC);
@@ -600,14 +614,14 @@
(dvoid *)OCI(pEnv),
OCI_HTYPE_ENV));
- oci_debug("END php_mshutdown_oci");
+ oci_debug("END php_mshutdown_oci");
return SUCCESS;
}
PHP_RSHUTDOWN_FUNCTION(oci)
{
- oci_debug("START php_rshutdown_oci");
+ oci_debug("START php_rshutdown_oci");
#if 0
/* XXX free all statements, rollback all outstanding transactions */
@@ -616,9 +630,9 @@
zend_hash_apply(OCI(server), (apply_func_t) _server_cleanup TSRMLS_CC);
#endif
- oci_debug("END php_rshutdown_oci");
+ oci_debug("END php_rshutdown_oci");
- return SUCCESS;
+ return SUCCESS;
}
@@ -627,7 +641,7 @@
php_info_print_table_start();
php_info_print_table_row(2, "OCI8 Support", "enabled");
- php_info_print_table_row(2, "Revision", "$Revision: 1.183.2.1 $");
+ php_info_print_table_row(2, "Revision", "$Revision: 1.183.2.2 $");
#ifndef PHP_WIN32
php_info_print_table_row(2, "Oracle Version", PHP_OCI8_VERSION );
php_info_print_table_row(2, "Compile-time ORACLE_HOME", PHP_OCI8_DIR );
@@ -665,7 +679,7 @@
oci_debug("_oci_bind_hash_dtor:");
- zval_ptr_dtor(&(bind->zval));
+ zval_ptr_dtor(&(bind->zval));
}
/* }}} */
@@ -678,7 +692,7 @@
/* reset all bind stuff to a normal state..-. */
- bind->indicator = 0;
+ bind->indicator = 0;
return 0;
}
@@ -863,8 +877,8 @@
zend_list_delete(coll->conn->id);
/* Note sure if we need to free the object. Have an
- oracle TAR out on this one.
- OCIDescriptorFree(descr->ocidescr, Z_TYPE_P(descr)); */
+ oracle TAR out on this one.
+ OCIDescriptorFree(descr->ocidescr, Z_TYPE_P(descr)); */
oci_debug("END _oci_coll_list_dtor: %d",coll->id);
@@ -880,7 +894,7 @@
_oci_descriptor_list_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
oci_descriptor *descr = (oci_descriptor *)rsrc->ptr;
- oci_debug("START _oci_descriptor_list_dtor: %d",descr->id);
+ oci_debug("START _oci_descriptor_list_dtor: %d",descr->id);
zend_list_delete(descr->conn->id);
@@ -888,7 +902,7 @@
descr->ocidescr,
Z_TYPE_P(descr)));
- oci_debug("END _oci_descriptor_list_dtor: %d",descr->id);
+ oci_debug("END _oci_descriptor_list_dtor: %d",descr->id);
efree(descr);
}
@@ -915,7 +929,7 @@
_oci_session_list_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
oci_session *session = (oci_session *)rsrc->ptr;
- if (session->persistent)
+ if (session->persistent)
return;
_oci_close_session(session);
@@ -933,16 +947,16 @@
zend_bailout();
break;
- case 22: /* ORA-00022 Invalid session id */
- case 1012: /* ORA-01012: */
- case 3113: /* ORA-03113: end-of-file on communication channel */
+ case 22: /* ORA-00022 Invalid session id */
+ case 1012: /* ORA-01012: */
+ case 3113: /* ORA-03113: end-of-file on communication channel */
case 604:
case 1041:
- connection->is_open = 0;
- connection->session->is_open = 0;
- connection->session->server->is_open = 0;
+ connection->is_open = 0;
+ connection->session->is_open = 0;
+ connection->session->server->is_open = 0;
return 1; /* fatal error */
- }
+ }
return 0; /* no fatal error */
}
@@ -953,23 +967,32 @@
static ub4
oci_error(OCIError *err_p, char *what, sword status)
{
- text errbuf[512];
- sb4 errcode = 0;
+ text errbuf[512];
+ sb4 errcode = 0;
+ TSRMLS_FETCH();
- switch (status) {
+ switch (status) {
case OCI_SUCCESS:
break;
case OCI_SUCCESS_WITH_INFO:
- php_error(E_WARNING, "%s: OCI_SUCCESS_WITH_INFO", what);
+ CALL_OCI(OCIErrorGet(
+ err_p,
+ (ub4)1,
+ NULL,
+ &errcode,
+ errbuf,
+ (ub4)sizeof(errbuf),
+ (ub4)OCI_HTYPE_ERROR));
+
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s:
+OCI_SUCCESS_WITH_INFO: %s", what, errbuf);
break;
case OCI_NEED_DATA:
- php_error(E_WARNING, "%s: OCI_NEED_DATA", what);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s: OCI_NEED_DATA", what);
break;
case OCI_NO_DATA:
- php_error(E_WARNING, "%s: OCI_NO_DATA", what);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s: OCI_NO_DATA", what);
break;
case OCI_ERROR: {
- TSRMLS_FETCH();
CALL_OCI(OCIErrorGet(
err_p,
(ub4)1,
@@ -979,22 +1002,22 @@
(ub4)sizeof(errbuf),
(ub4)OCI_HTYPE_ERROR));
- php_error(E_WARNING, "%s: %s", what, errbuf);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s: %s", what,
+errbuf);
break;
}
case OCI_INVALID_HANDLE:
- php_error(E_WARNING, "%s: OCI_INVALID_HANDLE", what);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s: OCI_INVALID_HANDLE",
+what);
break;
case OCI_STILL_EXECUTING:
- php_error(E_WARNING, "%s: OCI_STILL_EXECUTING", what);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s: OCI_STILL_EXECUTING",
+what);
break;
case OCI_CONTINUE:
- php_error(E_WARNING, "%s: OCI_CONTINUE", what);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s: OCI_CONTINUE", what);
break;
default:
break;
- }
- return errcode;
+ }
+ return errcode;
}
/* }}} */
@@ -1018,7 +1041,7 @@
oci_error(OCI(pError), "oci_ping", OCI(error));
- return 0;
+ return 0;
}
/* }}} */
@@ -1031,7 +1054,7 @@
{
TSRMLS_FETCH();
- if (OCI(debug_mode)) {
+ if (OCI(debug_mode)) {
char buffer[1024];
va_list args;
@@ -1100,29 +1123,30 @@
{
oci_out_column *outcol = NULL;
int i;
+ TSRMLS_FETCH();
if (statement->columns == 0) { /* we release the columns at the end of a fetch
*/
return NULL;
}
if (value) {
- if (Z_TYPE_PP(value) == IS_STRING) {
+ if (Z_TYPE_PP(value) == IS_STRING) {
for (i = 0; i < statement->ncolumns; i++) {
- outcol = oci_get_col(statement, i + 1, 0);
- if (outcol == NULL) {
- continue;
- } else if (((int) outcol->name_len == Z_STRLEN_PP(value))
- && (!
strncmp(outcol->name,Z_STRVAL_PP(value),Z_STRLEN_PP(value)))) {
- return outcol;
- }
- }
- } else {
+ outcol = oci_get_col(statement, i + 1, 0);
+ if (outcol == NULL) {
+ continue;
+ } else if (((int) outcol->name_len ==
+Z_STRLEN_PP(value))
+ && (!
+strncmp(outcol->name,Z_STRVAL_PP(value),Z_STRLEN_PP(value)))) {
+ return outcol;
+ }
+ }
+ } else {
convert_to_long_ex(value);
return oci_get_col(statement,Z_LVAL_PP(value),0);
}
} else if (col != -1) {
if (zend_hash_index_find(statement->columns, col, (void **)&outcol) ==
FAILURE) {
- php_error(E_WARNING, "Invalid column %d", col);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid column
+%d", col);
return NULL;
}
return outcol;
@@ -1142,21 +1166,21 @@
descr = emalloc(sizeof(oci_descriptor));
- Z_TYPE_P(descr) = type;
+ Z_TYPE_P(descr) = type;
switch (Z_TYPE_P(descr)) {
- case OCI_DTYPE_FILE:
- case OCI_DTYPE_LOB:
- case OCI_DTYPE_ROWID:
+ case OCI_DTYPE_FILE:
+ case OCI_DTYPE_LOB:
+ case OCI_DTYPE_ROWID:
break;
-
- default:
- php_error(E_WARNING, "Unknown descriptor type
%d.",Z_TYPE_P(descr));
+
+ default:
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown
+descriptor type %d.",Z_TYPE_P(descr));
return 0;
}
CALL_OCI_RETURN(OCI(error), OCIDescriptorAlloc(
- OCI(pEnv),
+ connection->session->pEnv,
(dvoid*)&(descr->ocidescr),
Z_TYPE_P(descr),
(size_t) 0,
@@ -1185,18 +1209,18 @@
static int
_oci_get_ocicoll(zval *id,oci_collection **collection TSRMLS_DC)
{
- zval **coll;
-
- if (zend_hash_find(Z_OBJPROP_P(id), "collection", sizeof("collection"), (void
**)&coll) == FAILURE) {
- php_error(E_WARNING, "cannot find collection");
- return 0;
- }
- if ((*collection = oci_get_coll(Z_LVAL_PP(coll) TSRMLS_CC)) == NULL) {
- php_error(E_WARNING, "collection not found");
- return 0;
- }
+ zval **coll;
+
+ if (zend_hash_find(Z_OBJPROP_P(id), "collection", sizeof("collection"), (void
+**)&coll) == FAILURE) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot find collection");
+ return 0;
+ }
+ if ((*collection = oci_get_coll(Z_LVAL_PP(coll) TSRMLS_CC)) == NULL) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "collection not found");
+ return 0;
+ }
- return Z_LVAL_PP(coll);
+ return Z_LVAL_PP(coll);
}
/* }}} */
@@ -1212,12 +1236,12 @@
zval **desc;
if (zend_hash_find(Z_OBJPROP_P(id), "descriptor", sizeof("descriptor"), (void
**)&desc) == FAILURE) {
- php_error(E_WARNING, "cannot find descriptor");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot find descriptor");
return 0;
}
if ((*descriptor = oci_get_desc(Z_LVAL_PP(desc) TSRMLS_CC)) == NULL) {
- php_error(E_WARNING, "descriptor not found");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "descriptor not found");
return 0;
}
@@ -1247,16 +1271,16 @@
if (column->is_cursor) { /* REFCURSOR -> simply return the statement id */
ZVAL_RESOURCE(value,column->stmtid);
- zend_list_addref(column->stmtid);
+ zend_list_addref(column->stmtid);
} else if (column->is_descr) {
if ((column->data_type != SQLT_RDD) && (mode & OCI_RETURN_LOBS)) {
/* OCI_RETURN_LOBS means that we want the content of the LOB
back instead of the locator */
descr = oci_get_desc(column->descid TSRMLS_CC);
- if (! descr) {
- php_error(E_WARNING, "unable to find my descriptor
%d",column->data);
- return -1;
- }
+ if (! descr) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to
+find my descriptor %d",column->data);
+ return -1;
+ }
if (oci_loadlob(statement->conn,descr,&buffer,&loblen)) {
ZVAL_FALSE(value);
@@ -1267,7 +1291,7 @@
/* return the locator */
object_init_ex(value, oci_lob_class_entry_ptr);
add_property_resource(value, "descriptor", column->descid);
- zend_list_addref(column->descid);
+ zend_list_addref(column->descid);
}
} else {
switch (column->retcode) {
@@ -1315,7 +1339,7 @@
statement->error = oci_error(statement->pError, "OCIAttrSet
OCI_ATTR_PREFETCH_MEMORY", error);
if (statement->error) {
- oci_handle_error(statement->conn, statement->error);
+ oci_handle_error(statement->conn, statement->error);
}
prefetch = size;
@@ -1328,7 +1352,7 @@
statement->pError));
statement->error = oci_error(statement->pError, "OCIAttrSet
OCI_ATTR_PREFETCH_MEMORY", error);
- if (statement->error) {
+ if (statement->error) {
oci_handle_error(statement->conn, statement->error);
}
@@ -1346,15 +1370,15 @@
statement = ecalloc(1,sizeof(oci_statement));
- CALL_OCI(OCIHandleAlloc(
- OCI(pEnv),
- (dvoid **)&statement->pStmt,
+ CALL_OCI(OCIHandleAlloc(
+ connection->session->pEnv,
+ (dvoid **)&statement->pStmt,
OCI_HTYPE_STMT,
0,
NULL));
- CALL_OCI(OCIHandleAlloc(
- OCI(pEnv),
+ CALL_OCI(OCIHandleAlloc(
+ connection->session->pEnv,
(dvoid **)&statement->pError,
OCI_HTYPE_ERROR,
0,
@@ -1375,7 +1399,7 @@
statement->pStmt,
OCI_HTYPE_STMT));
- CALL_OCI(OCIHandleFree(
+ CALL_OCI(OCIHandleFree(
statement->pError,
OCI_HTYPE_ERROR));
@@ -1395,9 +1419,9 @@
statement->id = zend_list_insert(statement,le_stmt);
oci_debug("oci_parse \"%s\" id=%d conn=%d",
- SAFE_STRING(query),
- statement->id,
- statement->conn->id);
+ SAFE_STRING(query),
+ statement->id,
+ statement->conn->id);
zend_list_addref(statement->conn->id);
@@ -1514,7 +1538,7 @@
memset(&column,0,sizeof(oci_out_column));
if (zend_hash_index_update(statement->columns, counter,
&column,
-
sizeof(oci_out_column), (void**) &outcol) == FAILURE) {
+
+sizeof(oci_out_column), (void**) &outcol) == FAILURE) {
efree(statement->columns);
/* out of memory */
return 0;
@@ -1648,11 +1672,11 @@
descr = oci_new_desc(dtype,statement->conn);
outcol->descid = descr->id;
- buf = &(descr->ocidescr);
+ buf = &(descr->ocidescr);
break;
case SQLT_LNG:
- case SQLT_LBI:
+ case SQLT_LBI:
if (outcol->data_type == SQLT_LBI) {
define_type = SQLT_BIN;
} else {
@@ -1673,7 +1697,7 @@
#ifdef SQLT_TIMESTAMP_TZ
|| (outcol->data_type ==
SQLT_TIMESTAMP_TZ)
#endif
- ) {
+ ) {
outcol->storage_size4 = 512; /* XXX
this should fit "most" NLS date-formats and Numbers */
} else {
outcol->storage_size4++; /* add one
for string terminator */
@@ -1688,32 +1712,32 @@
if (dynamic == OCI_DYNAMIC_FETCH) {
CALL_OCI_RETURN(error, OCIDefineByPos(
- statement->pStmt,
/* IN/OUT handle to the requested SQL query */
- (OCIDefine
**)&outcol->pDefine, /* IN/OUT pointer to a pointer to a
define handle */
- statement->pError,
/* IN/OUT An error handle */
- counter,
/* IN position in the select list
*/
- (dvoid *)NULL,
/* IN/OUT pointer to a buffer */
- outcol->storage_size4,
/* IN The size of each valuep buffer in bytes */
- define_type,
/* IN The data type */
- (dvoid *)&outcol->indicator,
/* IN pointer to an indicator variable or arr */
- (ub2 *)NULL,
/* IN/OUT Pointer to array of length of data fetched */
- (ub2 *)NULL,
/* OUT Pointer to array of column-level return codes */
- OCI_DYNAMIC_FETCH));
/* IN mode (OCI_DEFAULT, OCI_DYNAMIC_FETCH) */
+ statement->pStmt,
+ /* IN/OUT handle to the requested SQL query */
+ (OCIDefine
+**)&outcol->pDefine, /* IN/OUT pointer to a pointer to a define handle */
+ statement->pError,
+ /* IN/OUT An error handle */
+ counter,
+ /* IN position in the select list */
+ (dvoid *)NULL,
+ /* IN/OUT pointer to a buffer */
+ outcol->storage_size4,
+ /* IN The size of each valuep buffer in bytes */
+ define_type,
+ /* IN The data type */
+ (dvoid *)&outcol->indicator,
+ /* IN pointer to an indicator variable or arr */
+ (ub2 *)NULL,
+ /* IN/OUT Pointer to array of length of data fetched */
+ (ub2 *)NULL,
+ /* OUT Pointer to array of column-level return codes */
+ OCI_DYNAMIC_FETCH));
+ /* IN mode (OCI_DEFAULT, OCI_DYNAMIC_FETCH) */
statement->error = oci_error(statement->pError,
"OCIDefineByPos", error);
} else {
CALL_OCI_RETURN(error, OCIDefineByPos(
- statement->pStmt,
/* IN/OUT handle to the requested SQL query
*/
- (OCIDefine
**)&outcol->pDefine, /* IN/OUT pointer to a pointer to a
define handle */
- statement->pError,
/* IN/OUT An error handle */
- counter,
/* IN position in the select list
*/
- (dvoid *)buf,
/* IN/OUT pointer to a buffer */
- outcol->storage_size4,
/* IN The size of each valuep buffer in bytes */
- define_type,
/* IN The data type */
- (dvoid *)&outcol->indicator,
/* IN pointer to an indicator variable or arr */
- (ub2 *)&outcol->retlen,
/* IN/OUT Pointer to array of length of data fetched
*/
- (ub2 *)&outcol->retcode,
/* OUT Pointer to array of column-level return
codes */
- OCI_DEFAULT));
/* IN mode (OCI_DEFAULT, OCI_DYNAMIC_FETCH) */
+ statement->pStmt,
+ /* IN/OUT handle to the requested SQL query */
+ (OCIDefine
+**)&outcol->pDefine, /* IN/OUT pointer to a pointer to a define handle */
+ statement->pError,
+ /* IN/OUT An error handle */
+ counter,
+ /* IN position in the select list */
+ (dvoid *)buf,
+ /* IN/OUT pointer to a buffer */
+ outcol->storage_size4,
+ /* IN The size of each valuep buffer in bytes */
+ define_type,
+ /* IN The data type */
+ (dvoid *)&outcol->indicator,
+ /* IN pointer to an indicator variable or arr */
+ (ub2 *)&outcol->retlen,
+ /* IN/OUT Pointer to array of length of data fetched */
+ (ub2 *)&outcol->retcode,
+ /* OUT Pointer to array of column-level return codes */
+ OCI_DEFAULT));
+ /* IN mode (OCI_DEFAULT, OCI_DYNAMIC_FETCH) */
statement->error = oci_error(statement->pError,
"OCIDefineByPos", error);
}
@@ -1735,7 +1759,7 @@
{
oci_out_column *col = (oci_out_column *) data;
- if (col->piecewise) {
+ if (col->piecewise) {
col->retlen4 = 0;
}
@@ -1801,7 +1825,7 @@
&column->indicator,
&column->retcode));
}
- }
+ }
CALL_OCI_RETURN(statement->error, OCIStmtFetch(
statement->pStmt,
@@ -1901,7 +1925,7 @@
readlen,
/* size of buffer */
(dvoid *)0,
(OCICallbackLobRead) 0, /* callback...
*/
- (ub2) 0,
/* The character set ID of the buffer data. */
+ (ub2) connection->session->charsetId,
+ /* The character set ID of the buffer data. */
(ub1) SQLCS_IMPLICIT)); /* The
character set form of the buffer data. */
siz += readlen;
@@ -1951,10 +1975,10 @@
#if 0 /* not needed yet ! */
static sb4
oci_failover_callback(dvoid *svchp,
- dvoid* envhp,
- dvoid *fo_ctx,
- ub4 fo_type,
- ub4 fo_event)
+ dvoid* envhp,
+ dvoid *fo_ctx,
+ ub4 fo_type,
+ ub4 fo_event)
{
/*
this stuff is from an oci sample - it will get cleaned up as soon as i
understand it!!! ([EMAIL PROTECTED] 990420)
@@ -1967,12 +1991,12 @@
{
printf(" Failing Over ... Please stand by \n");
printf(" Failover type was found to be %s \n",
- ((fo_type==OCI_FO_NONE) ? "NONE"
+ ((fo_type==OCI_FO_NONE) ? "NONE"
:(fo_type==OCI_FO_SESSION) ? "SESSION"
:(fo_type==OCI_FO_SELECT) ? "SELECT"
: "UNKNOWN!"));
printf(" Failover Context is :%s\n",
- (fo_ctx?(char *)fo_ctx:"NULL POINTER!"));
+ (fo_ctx?(char *)fo_ctx:"NULL
+POINTER!"));
break;
}
@@ -2037,9 +2061,10 @@
{
oci_bind *phpbind;
zval *val;
+ TSRMLS_FETCH();
if (!(phpbind=(oci_bind *)ictxp) || !(val = phpbind->zval)) {
- php_error(E_WARNING, "!phpbind || !phpbind->val");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "!phpbind ||
+!phpbind->val");
return OCI_ERROR;
}
@@ -2058,7 +2083,7 @@
*indpp = (dvoid *)&phpbind->indicator;
} else if (phpbind->pStmt != 0) {
/* RSET */
- *bufpp = phpbind->pStmt;
+ *bufpp = phpbind->pStmt;
*alenp = -1; /* seems to be allright */
*indpp = (dvoid *)&phpbind->indicator;
} else {
@@ -2090,9 +2115,10 @@
oci_bind *phpbind;
zval *val;
sb4 retval = OCI_ERROR;
+ TSRMLS_FETCH();
if (!(phpbind=(oci_bind *)octxp) || !(val = phpbind->zval)) {
- php_error(E_WARNING, "!phpbind || !phpbind->val");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "!phpbind ||
+!phpbind->val");
return retval;
}
@@ -2122,12 +2148,15 @@
*/
-static oci_session *_oci_open_session(oci_server* server,char *username,char
*password,int persistent,int exclusive)
+static oci_session *_oci_open_session(oci_server* server,char *username,char
+*password,int persistent,int exclusive,char *charset)
{
oci_session *session = 0, *psession = 0;
OCISvcCtx *svchp = 0;
char *hashed_details;
- TSRMLS_FETCH();
+#ifdef HAVE_OCI9
+ ub2 charsetid;
+#endif
+ TSRMLS_FETCH();
/*
check if we already have this user authenticated
@@ -2175,9 +2204,48 @@
session->server = server;
session->exclusive = exclusive;
+#ifdef HAVE_OCI9
+
+ /* following chunk is Oracle 9i+ ONLY */
+ if (*charset) {
+ /*
+ get ub2 charset id based on charset
+ this is pretty secure, since if we don't have a valid character set
+name,
+ 0 comes back and we can still use the 0 in all further statements
+-> OCI uses NLS_LANG
+ setting in that case
+ */
+ CALL_OCI_RETURN(charsetid, OCINlsCharSetNameToId(
+ OCI(pEnv),
+ charset));
+
+ session->charsetId = charsetid;
+ oci_debug("oci_do_connect: using charset id=%d",charsetid);
+ }
+
+ /* create an environment using the character set id, Oracle 9i+ ONLY */
+ CALL_OCI(OCIEnvNlsCreate(
+ &session->pEnv,
+ OCI_DEFAULT,
+ 0,
+ NULL,
+ NULL,
+ NULL,
+ 0,
+ NULL,
+ charsetid,
+ charsetid));
+
+#else
+
+ /* fallback solution (simply use global env and charset, same behaviour as
+always been) */
+ session->pEnv = OCI(pEnv);
+ session->charsetId = 0;
+
+#endif /* HAVE_OCI9 */
+
/* allocate temporary Service Context */
CALL_OCI_RETURN(OCI(error), OCIHandleAlloc(
- OCI(pEnv),
+ session->pEnv,
(dvoid **)&svchp,
OCI_HTYPE_SVCCTX,
0,
@@ -2190,7 +2258,7 @@
/* allocate private session-handle */
CALL_OCI_RETURN(OCI(error), OCIHandleAlloc(
- OCI(pEnv),
+ session->pEnv,
(dvoid **)&session->pSession,
OCI_HTYPE_SESSION,
0,
@@ -2308,7 +2376,7 @@
if (session->is_open) {
/* Temporary Service Context */
CALL_OCI_RETURN(OCI(error), OCIHandleAlloc(
- OCI(pEnv),
+ session->pEnv,
(dvoid **) &svchp,
(ub4) OCI_HTYPE_SVCCTX,
(size_t) 0,
@@ -2384,7 +2452,7 @@
static oci_server *_oci_open_server(char *dbname,int persistent)
{
oci_server *server, *pserver = 0;
- TSRMLS_FETCH();
+ TSRMLS_FETCH();
/*
check if we already have this server open
@@ -2470,11 +2538,11 @@
server->failover.callback_function = oci_failover_callback;
error = OCIAttrSet((dvoid *)server->pServer,
- (ub4) OCI_HTYPE_SERVER,
- (dvoid *) &server->failover,
- (ub4) 0,
- (ub4) OCI_ATTR_FOCBK,
- OCI(pError));
+ (ub4) OCI_HTYPE_SERVER,
+ (dvoid *) &server->failover,
+ (ub4) 0,
+ (ub4) OCI_ATTR_FOCBK,
+ OCI(pError));
if (error) {
oci_error(OCI(pError), "_oci_open_server OCIAttrSet OCI_ATTR_FOCBK",
error);
@@ -2554,13 +2622,25 @@
*/
static void oci_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent,int exclusive)
{
- char *username, *password, *dbname;
- zval **userParam, **passParam, **dbParam;
- oci_server *server = 0;
- oci_session *session = 0;
- oci_connection *connection = 0;
+ char *username, *password, *dbname, *charset;
+ zval **userParam, **passParam, **dbParam, **charParam;
+ oci_server *server = 0;
+ oci_session *session = 0;
+ oci_connection *connection = 0;
- if (zend_get_parameters_ex(3, &userParam, &passParam, &dbParam) == SUCCESS) {
+ /* if a forth parameter is handed over, it is the charset identifier (but is
+only used in Oracle 9i+) */
+ if (zend_get_parameters_ex(4, &userParam, &passParam, &dbParam, &charParam) ==
+SUCCESS) {
+ convert_to_string_ex(userParam);
+ convert_to_string_ex(passParam);
+ convert_to_string_ex(dbParam);
+ convert_to_string_ex(charParam);
+
+ username = Z_STRVAL_PP(userParam);
+ password = Z_STRVAL_PP(passParam);
+ dbname = Z_STRVAL_PP(dbParam);
+ charset = Z_STRVAL_PP(charParam);
+ oci_debug("oci_do_connect: using charset=%s",charset);
+ } else if (zend_get_parameters_ex(3, &userParam, &passParam, &dbParam) ==
+SUCCESS) {
convert_to_string_ex(userParam);
convert_to_string_ex(passParam);
convert_to_string_ex(dbParam);
@@ -2568,16 +2648,16 @@
username = Z_STRVAL_PP(userParam);
password = Z_STRVAL_PP(passParam);
dbname = Z_STRVAL_PP(dbParam);
- } else if (zend_get_parameters_ex(2, &userParam, &passParam) == SUCCESS) {
+ } else if (zend_get_parameters_ex(2, &userParam, &passParam) == SUCCESS) {
convert_to_string_ex(userParam);
convert_to_string_ex(passParam);
username = Z_STRVAL_PP(userParam);
password = Z_STRVAL_PP(passParam);
dbname = "";
- } else {
+ } else {
WRONG_PARAM_COUNT;
- }
+ }
connection = (oci_connection *) ecalloc(1,sizeof(oci_connection));
@@ -2599,7 +2679,7 @@
persistent = server->persistent;
}
- session = _oci_open_session(server,username,password,persistent,exclusive);
+ session =
+_oci_open_session(server,username,password,persistent,exclusive,charset);
if (! session) {
goto CLEANUP;
@@ -2610,7 +2690,7 @@
/* allocate our private error-handle */
CALL_OCI_RETURN(OCI(error), OCIHandleAlloc(
- OCI(pEnv),
+ connection->session->pEnv,
(dvoid **)&connection->pError,
OCI_HTYPE_ERROR,
0,
@@ -2623,7 +2703,7 @@
/* allocate our service-context */
CALL_OCI_RETURN(OCI(error), OCIHandleAlloc(
- OCI(pEnv),
+ connection->session->pEnv,
(dvoid **)&connection->pServiceContext,
OCI_HTYPE_SVCCTX,
0,
@@ -2664,18 +2744,18 @@
/*
OCIAttrSet((dvoid *)session->server->pServer,
- OCI_HTYPE_SERVER,
- (dvoid *) "demo",
- 0,
- OCI_ATTR_EXTERNAL_NAME,
- connection->pError);
+ OCI_HTYPE_SERVER,
+ (dvoid *) "demo",
+ 0,
+ OCI_ATTR_EXTERNAL_NAME,
+ connection->pError);
OCIAttrSet((dvoid *)session->server->pServer,
- OCI_HTYPE_SERVER,
- (dvoid *) "txn demo2",
- 0,
- OCI_ATTR_INTERNAL_NAME,
- connection->pError);
+ OCI_HTYPE_SERVER,
+ (dvoid *) "txn demo2",
+ 0,
+ OCI_ATTR_INTERNAL_NAME,
+ connection->pError);
*/
connection->id = zend_list_insert(connection, le_conn);
@@ -2715,11 +2795,11 @@
ub2 ocitype = SQLT_CHR; /* zero terminated string */
int ac = ZEND_NUM_ARGS();
- if (ac < 3 || ac > 4 || zend_get_parameters_ex(ac, &stmt, &name, &var, &type) ==
FAILURE) {
- WRONG_PARAM_COUNT;
- }
+ if (ac < 3 || ac > 4 || zend_get_parameters_ex(ac, &stmt, &name, &var, &type)
+== FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
- switch (ac) {
+ switch (ac) {
case 4:
convert_to_long_ex(type);
ocitype = (ub2) Z_LVAL_PP(type);
@@ -2774,21 +2854,21 @@
oci_bind bind, *bindp;
oci_descriptor *descr;
#ifdef WITH_COLLECTIONS
- oci_collection *coll;
- dvoid *mycoll = 0;
+ oci_collection *coll;
+ dvoid *mycoll = 0;
#endif
int mode = OCI_DATA_AT_EXEC;
ub2 ocitype = SQLT_CHR; /* unterminated string */
- OCIStmt *mystmt = 0;
+ OCIStmt *mystmt = 0;
dvoid *mydescr = 0;
sb4 value_sz = -1;
int ac = ZEND_NUM_ARGS(), inx;
- if (ac < 3 || ac > 5 || zend_get_parameters_ex(ac, &stmt, &name, &var, &maxlen,
&type) == FAILURE) {
+ if (ac < 3 || ac > 5 || zend_get_parameters_ex(ac, &stmt, &name, &var,
+&maxlen, &type) == FAILURE) {
WRONG_PARAM_COUNT;
- }
+ }
- switch (ac) {
+ switch (ac) {
case 5:
convert_to_long_ex(type);
ocitype = (ub2) Z_LVAL_PP(type);
@@ -2803,22 +2883,22 @@
switch (ocitype) {
#ifdef WITH_COLLECTIONS
- case SQLT_NTY:
+ case SQLT_NTY:
if(Z_TYPE_PP(var) != IS_OBJECT) {
- php_error(E_WARNING,"Variable must be allocated using
OCINewCollection()");
- RETURN_FALSE;
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Variable
+must be allocated using OCINewCollection()");
+ RETURN_FALSE;
}
- if ((inx = _oci_get_ocicoll(*var,&coll TSRMLS_CC)) == 0) {
- php_error(E_WARNING,"Variable must be allocated using
OCINewCollection()");
- RETURN_FALSE;
- }
- if (! (mycoll = (dvoid *) coll->coll)) {
- php_error(E_WARNING,"Collection empty");
- RETURN_FALSE;
- }
- value_sz = sizeof(void*);
- mode = OCI_DEFAULT;
- break;
+ if ((inx = _oci_get_ocicoll(*var,&coll TSRMLS_CC)) == 0) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Variable
+must be allocated using OCINewCollection()");
+ RETURN_FALSE;
+ }
+ if (! (mycoll = (dvoid *) coll->coll)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,
+"Collection empty");
+ RETURN_FALSE;
+ }
+ value_sz = sizeof(void*);
+ mode = OCI_DEFAULT;
+break;
#endif
case SQLT_BFILEE:
case SQLT_CFILEE:
@@ -2826,17 +2906,17 @@
case SQLT_BLOB:
case SQLT_RDD:
if (Z_TYPE_PP(var) != IS_OBJECT) {
- php_error(E_WARNING,"Variable must be allocated using
OCINewDescriptor()");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Variable
+must be allocated using OCINewDescriptor()");
RETURN_FALSE;
}
if ((inx = _oci_get_ocidesc(*var,&descr TSRMLS_CC)) == 0) {
- php_error(E_WARNING,"Variable must be allocated using
OCINewDescriptor()");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Variable
+must be allocated using OCINewDescriptor()");
RETURN_FALSE;
}
if (! (mydescr = (dvoid *) descr->ocidescr)) {
- php_error(E_WARNING,"Descriptor empty");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,
+"Descriptor empty");
RETURN_FALSE;
}
value_sz = sizeof(void*);
@@ -2878,19 +2958,19 @@
CALL_OCI_RETURN(statement->error, OCIBindByName(
statement->pStmt, /* statement handle */
- (OCIBind **)&bindp->pBind, /* bind hdl (will alloc)
*/
- statement->pError, /* error handle */
- (text*) Z_STRVAL_PP(name), /* placeholder name */
- Z_STRLEN_PP(name), /* placeholder length */
- (dvoid *)0, /* in/out data */
- value_sz, /* OCI_MAX_DATA_SIZE, */ /* max
size of input/output data */
- (ub2)ocitype, /* in/out data type */
- (dvoid *)&bindp->indicator, /* indicator (ignored) */
- (ub2 *)0, /* size array (ignored) */
- (ub2 *)&bindp->retcode, /* return code (ignored)
*/
- (ub4)0, /* maxarr_len (PL/SQL
only?) */
- (ub4 *)0, /* actual array size
(PL/SQL only?) */
- mode /* mode */
+ (OCIBind **)&bindp->pBind, /* bind hdl (will
+alloc) */
+ statement->pError, /* error handle */
+ (text*) Z_STRVAL_PP(name), /* placeholder name */
+
+ Z_STRLEN_PP(name), /* placeholder length */
+ (dvoid *)0, /* in/out data */
+ value_sz, /* OCI_MAX_DATA_SIZE, */ /*
+max size of input/output data */
+ (ub2)ocitype, /* in/out data type */
+ (dvoid *)&bindp->indicator, /* indicator
+(ignored) */
+ (ub2 *)0, /* size array
+(ignored) */
+ (ub2 *)&bindp->retcode, /* return code
+(ignored) */
+ (ub4)0, /* maxarr_len (PL/SQL
+only?) */
+ (ub4 *)0, /* actual array size
+(PL/SQL only?) */
+ mode /* mode */
));
if (statement->error != OCI_SUCCESS) {
@@ -2957,7 +3037,7 @@
}
}
- php_error(E_NOTICE, "OCIFreeDesc() should not be called like this. Use
$somelob->free() to free a LOB");
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "OCIFreeDesc() should not be called
+like this. Use $somelob->free() to free a LOB");
RETURN_FALSE;
}
@@ -2974,8 +3054,8 @@
oci_descriptor *descr;
int offparam,inx;
ub4 loblen;
- ub4 curloblen;
- ub4 offset;
+ ub4 curloblen;
+ ub4 offset;
if ((id = getThis()) != 0) {
if ((inx = _oci_get_ocidesc(id,&descr TSRMLS_CC)) == 0) {
@@ -2991,7 +3071,7 @@
connection = descr->conn;
offset = 0;
- if (zend_get_parameters_ex(2, &arg, &oarg) == SUCCESS) {
+ if (zend_get_parameters_ex(2, &arg, &oarg) == SUCCESS) {
convert_to_long_ex(oarg);
offparam = Z_LVAL_PP(oarg);
@@ -3006,21 +3086,21 @@
if (offparam == -1) {
offset = curloblen;
} else if ((ub4) offparam >= curloblen) {
- php_error(E_WARNING, "Offset smaller than current
LOB-Size - appending");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset
+smaller than current LOB-Size - appending");
offset = curloblen;
} else {
offset = offparam;
}
- } else if (zend_get_parameters_ex(1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
+ } else if (zend_get_parameters_ex(1, &arg) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
offset++;
convert_to_string_ex(arg);
loblen = Z_STRLEN_PP(arg);
if (loblen < 1) {
- php_error(E_WARNING, "Cannot save a lob which size is less
than 1 byte");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot save a lob
+which size is less than 1 byte");
RETURN_FALSE;
}
@@ -3082,9 +3162,9 @@
connection = descr->conn;
- if (zend_get_parameters_ex(1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
+ if (zend_get_parameters_ex(1, &arg) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
convert_to_string_ex(arg);
@@ -3095,9 +3175,9 @@
filename = Z_STRVAL_PP(arg);
if ((fp = VCWD_OPEN(filename, O_RDONLY|O_BINARY)) == -1) {
- php_error(E_WARNING, "Can't open file %s", filename);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't open file
+%s", filename);
RETURN_FALSE;
- }
+ }
while ((loblen = read(fp, &buf, sizeof(buf))) > 0) {
CALL_OCI_RETURN(connection->error, OCILobWrite(
@@ -3191,9 +3271,9 @@
connection = descr->conn;
- if (ac < 0 || ac > 3 || zend_get_parameters_ex(ac, &zfilename, &zstart,
&zlength) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
+ if (ac < 0 || ac > 3 || zend_get_parameters_ex(ac, &zfilename,
+&zstart, &zlength) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
switch (ac) {
case 3:
@@ -3213,7 +3293,7 @@
}
if ((fp = VCWD_OPEN_MODE(filename,O_CREAT | O_RDWR | O_BINARY
| O_TRUNC, 0600)) == -1) {
- php_error(E_WARNING, "Can't create file %s", filename);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't
+create file %s", filename);
goto bail;
}
}
@@ -3277,16 +3357,16 @@
CALL_OCI_RETURN(connection->error, OCILobRead(
connection->pServiceContext,
- connection->pError,
- descr->ocidescr,
- &toread, /*
IN/OUT bytes toread/read */
- coffs+1, /*
offset (starts with 1) */
- (dvoid *) buffer,
- toread, /*
size of buffer */
- (dvoid *)0,
- (OCICallbackLobRead) 0, /* callback... */
- (ub2) 0, /* The
character set ID of the buffer data. */
- (ub1) SQLCS_IMPLICIT)); /* The character
set form of the buffer data. */
+ connection->pError,
+ descr->ocidescr,
+ &toread, /* IN/OUT
+bytes toread/read */
+ coffs+1, /* offset
+(starts with 1) */
+ (dvoid *) buffer,
+ toread, /* size of
+buffer */
+ (dvoid *)0,
+ (OCICallbackLobRead) 0, /* callback...
+*/
+ (ub2) 0, /* The
+character set ID of the buffer data. */
+ (ub1) SQLCS_IMPLICIT)); /* The
+character set form of the buffer data. */
oci_debug("OCILobRead(read - %d",toread);
@@ -3298,7 +3378,7 @@
if (fp != -1) {
if ((ub4) write(fp,buffer,toread) != toread) {
- php_error(E_WARNING, "cannot write file!");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,
+"cannot write file!");
goto bail;
}
} else {
@@ -3351,36 +3431,36 @@
PHP_FUNCTION(ociwritetemporarylob)
{
- zval *id, **var;
+ zval *id, **var;
OCILobLocator *mylob;
oci_connection *connection;
oci_descriptor *descr;
ub4 offset = 1;
ub4 loblen;
- oci_debug ("oci_write_temporary_lob");
+ oci_debug ("oci_write_temporary_lob");
if ((id = getThis()) == 0) {
- RETURN_FALSE;
- }
+ RETURN_FALSE;
+ }
- if (_oci_get_ocidesc(id,&descr TSRMLS_CC) == 0) {
- RETURN_FALSE;
- }
+ if (_oci_get_ocidesc(id,&descr TSRMLS_CC) == 0) {
+ RETURN_FALSE;
+ }
- mylob = (OCILobLocator *) descr->ocidescr;
+ mylob = (OCILobLocator *) descr->ocidescr;
- if (! mylob) {
- RETURN_FALSE;
- }
+ if (! mylob) {
+ RETURN_FALSE;
+ }
- connection = descr->conn;
+ connection = descr->conn;
- if (zend_get_parameters_ex(1, &var) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
+ if (zend_get_parameters_ex(1, &var) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
- convert_to_string_ex(var);
+ convert_to_string_ex(var);
CALL_OCI_RETURN(connection->error, OCILobCreateTemporary(
connection->pServiceContext,
@@ -3389,14 +3469,14 @@
OCI_DEFAULT,
OCI_DEFAULT,
OCI_TEMP_CLOB,
- OCI_ATTR_NOCACHE,
- OCI_DURATION_STATEMENT));
+ OCI_ATTR_NOCACHE,
+ OCI_DURATION_SESSION));
- if (connection->error) {
- oci_error(connection->pError, "OCILobCreateTemporary", connection->error);
- oci_handle_error(connection, connection->error);
- RETURN_FALSE;
- }
+ if (connection->error) {
+ oci_error(connection->pError, "OCILobCreateTemporary",
+connection->error);
+ oci_handle_error(connection, connection->error);
+ RETURN_FALSE;
+ }
CALL_OCI_RETURN(connection->error, OCILobOpen(
connection->pServiceContext,
@@ -3404,19 +3484,19 @@
mylob,
OCI_LOB_READWRITE));
- if (connection->error) {
- oci_error(connection->pError, "OCILobOpen", connection->error);
- oci_handle_error(connection, connection->error);
- RETURN_FALSE;
- }
-
- convert_to_string_ex(var);
- loblen = Z_STRLEN_PP(var);
-
- if (loblen < 1) {
- php_error(E_WARNING, "Cannot save a lob that is less than 1 byte");
- RETURN_FALSE;
- }
+ if (connection->error) {
+ oci_error(connection->pError, "OCILobOpen", connection->error);
+ oci_handle_error(connection, connection->error);
+ RETURN_FALSE;
+ }
+
+ convert_to_string_ex(var);
+ loblen = Z_STRLEN_PP(var);
+
+ if (loblen < 1) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot save a lob that is
+less than 1 byte");
+ RETURN_FALSE;
+ }
CALL_OCI_RETURN(connection->error, OCILobWrite(
connection->pServiceContext,
@@ -3432,13 +3512,13 @@
(ub2) 0,
(ub1) SQLCS_IMPLICIT));
- if (connection->error) {
- oci_error(connection->pError, "OCILobWrite", connection->error);
- oci_handle_error(connection, connection->error);
- RETURN_FALSE;
- }
+ if (connection->error) {
+ oci_error(connection->pError, "OCILobWrite", connection->error);
+ oci_handle_error(connection, connection->error);
+ RETURN_FALSE;
+ }
- RETURN_TRUE;
+ RETURN_TRUE;
}
/* }}} */
@@ -3453,59 +3533,59 @@
OCILobLocator *mylob;
oci_connection *connection;
oci_descriptor *descriptor;
- int is_temporary;
+ int is_temporary;
if ((id = getThis()) != 0) {
inx = _oci_get_ocidesc(id,&descriptor TSRMLS_CC);
if (inx) {
- mylob = (OCILobLocator *) descriptor->ocidescr;
+ mylob = (OCILobLocator *) descriptor->ocidescr;
- if (! mylob) {
- RETURN_FALSE;
- }
+ if (! mylob) {
+ RETURN_FALSE;
+ }
- connection = descriptor->conn;
+ connection = descriptor->conn;
CALL_OCI_RETURN(connection->error, OCILobClose(
connection->pServiceContext,
connection->pError,
mylob));
- if (connection->error) {
- oci_error(connection->pError, "OCILobClose", connection->error);
- oci_handle_error(connection, connection->error);
- RETURN_FALSE;
- }
-
- connection->error =
- OCILobIsTemporary(OCI(pEnv),
- connection->pError,
- mylob,
- &is_temporary);
- if (is_temporary) {
- connection->error =
- OCILobFreeTemporary(connection->pServiceContext,
- connection->pError,
- mylob);
-
- if (connection->error) {
- oci_error(connection->pError, "OCILobFreeTemporary",
- connection->error);
- oci_handle_error(connection, connection->error);
- RETURN_FALSE;
- }
- oci_debug("oci_lob_free_temporary: descr=%d",inx);
- }
+ if (connection->error) {
+ oci_error(connection->pError, "OCILobClose",
+connection->error);
+ oci_handle_error(connection, connection->error);
+ RETURN_FALSE;
+ }
+
+ connection->error =
+ OCILobIsTemporary(connection->session->pEnv,
+
+connection->pError,
+ mylob,
+ &is_temporary);
+ if (is_temporary) {
+ connection->error =
+
+OCILobFreeTemporary(connection->pServiceContext,
+
+connection->pError,
+ mylob);
+
+ if (connection->error) {
+ oci_error(connection->pError,
+"OCILobFreeTemporary",
+ connection->error);
+ oci_handle_error(connection,
+connection->error);
+ RETURN_FALSE;
+ }
+ oci_debug("oci_lob_free_temporary: descr=%d",inx);
+ }
oci_debug("oci_close_lob: descr=%d",inx);
RETURN_TRUE;
}
}
- php_error(E_NOTICE, "OCICloselob() should not be called like this. Use
$somelob->close() to close a LOB");
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "OCICloselob() should not be called
+like this. Use $somelob->close() to close a LOB");
- RETURN_FALSE;
+ RETURN_FALSE;
}
/* }}} */
@@ -3521,7 +3601,7 @@
oci_descriptor *descr;
int dtype;
- dtype = OCI_DTYPE_LOB;
+ dtype = OCI_DTYPE_LOB;
if (zend_get_parameters_ex(2, &conn, &type) == SUCCESS) {
convert_to_long_ex(type);
@@ -3534,7 +3614,7 @@
descr = oci_new_desc(dtype,connection);
- object_init_ex(return_value, oci_lob_class_entry_ptr);
+ object_init_ex(return_value, oci_lob_class_entry_ptr);
add_property_resource(return_value, "descriptor", descr->id);
}
@@ -3554,7 +3634,7 @@
OCI_GET_CONN(connection,conn);
- oci_debug("<OCITransRollback");
+ oci_debug("<OCITransRollback");
CALL_OCI_RETURN(connection->error, OCITransRollback(
connection->pServiceContext,
@@ -3563,7 +3643,7 @@
connection->needs_commit = 0;
- oci_debug(">OCITransRollback");
+ oci_debug(">OCITransRollback");
if (connection->error) {
oci_error(connection->pError, "OCIRollback", connection->error);
@@ -3590,7 +3670,7 @@
OCI_GET_CONN(connection,conn);
- oci_debug("<OCITransCommit");
+ oci_debug("<OCITransCommit");
CALL_OCI_RETURN(connection->error, OCITransCommit(
connection->pServiceContext,
@@ -3599,7 +3679,7 @@
connection->needs_commit = 0;
- oci_debug(">OCITransCommit");
+ oci_debug(">OCITransCommit");
if (connection->error) {
oci_error(connection->pError, "OCICommit", connection->error);
@@ -3951,11 +4031,11 @@
int mode = OCI_NUM;
int ac = ZEND_NUM_ARGS();
- if (ac < 2 || ac > 3 || zend_get_parameters_ex(ac, &stmt, &array, &fmode) ==
FAILURE) {
- WRONG_PARAM_COUNT;
- }
+ if (ac < 2 || ac > 3 || zend_get_parameters_ex(ac, &stmt, &array, &fmode) ==
+FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
- switch (ac) {
+ switch (ac) {
case 3:
convert_to_long_ex(fmode);
mode = Z_LVAL_PP(fmode);
@@ -3969,10 +4049,7 @@
}
zval_dtor(*array);
- if (array_init(*array) == FAILURE) {
- php_error(E_WARNING, "OCIFetchInto: unable to convert arg 2 to array");
- RETURN_FALSE;
- }
+ array_init(*array);
for (i = 0; i < statement->ncolumns; i++) {
column = oci_get_col(statement, i + 1, 0);
@@ -4026,7 +4103,7 @@
WRONG_PARAM_COUNT;
}
- switch (ac) {
+ switch (ac) {
case 5:
convert_to_long_ex(zflags);
flags = Z_LVAL_PP(zflags);
@@ -4170,8 +4247,8 @@
request-end. connection handles will "dissappear" as soon as they are no
longer
referenced. as this module makes heavy use of zends reference-counting
mechanism
this is the desired behavior. it has always been a bad idea to close a
connection that
- has outstanding transactions. this way we have a nice-clean approach.
- ([EMAIL PROTECTED] 20000110)
+ has outstanding transactions. this way we have a nice-clean approach.
+ ([EMAIL PROTECTED] 20000110)
oci_connection *connection;
zval **conn;
@@ -4297,7 +4374,7 @@
}
if (! errh) {
- php_error(E_WARNING, "OCIError: unable to find Error handle");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "OCIError: unable to find
+Error handle");
RETURN_FALSE;
}
@@ -4395,6 +4472,58 @@
/* }}} */
+/* {{{ proto bool ocipasswordchange(int conn, string username, string old_password,
+string new_password)
+ changes the password of an account*/
+
+PHP_FUNCTION(ocipasswordchange)
+{
+ zval **conn, **user_param, **pass_old_param, **pass_new_param;
+ text *user, *pass_old, *pass_new;
+ oci_connection *connection;
+
+ /* Disable in Safe Mode */
+ if (PG(safe_mode)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "is disabled in Safe
+Mode");
+ RETURN_FALSE;
+ }
+
+ if (zend_get_parameters_ex(4, &conn, &user_param, &pass_old_param,
+&pass_new_param) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ user = Z_STRVAL_PP(user_param);
+ pass_old = Z_STRVAL_PP(pass_old_param);
+ pass_new = Z_STRVAL_PP(pass_new_param);
+
+ OCI_GET_CONN(connection, conn);
+
+ CALL_OCI_RETURN(
+ connection->error
+ ,OCIPasswordChange(
+ connection->pServiceContext
+ ,connection->pError
+ ,user
+ ,strlen(user)+1
+ ,pass_old
+ ,strlen(pass_old)+1
+ ,pass_new
+ ,strlen(pass_new)+1
+ ,OCI_DEFAULT
+ )
+ );
+
+ if (connection->error == OCI_SUCCESS) {
+ RETURN_TRUE;
+ }
+ else {
+ oci_error(connection->pError, "OCIPasswordChange", connection->error);
+ oci_handle_error(connection, connection->error);
+ RETURN_FALSE;
+ }
+}
+
+/* }}} */
+
/* {{{ proto int ocinewcursor(int conn)
Return a new cursor (Statement-Handle) - use this to bind ref-cursors! */
@@ -4580,16 +4709,16 @@
static oci_collection *oci_get_coll(int ind TSRMLS_DC)
{
- oci_collection *collection;
- int actual_resource_type;
+ oci_collection *collection;
+ int actual_resource_type;
- collection = (oci_collection *) zend_list_find(ind, &actual_resource_type);
+ collection = (oci_collection *) zend_list_find(ind, &actual_resource_type);
- if (collection && (actual_resource_type == le_coll)) {
- return collection;
- } else {
- return (oci_collection *) NULL;
- }
+ if (collection && (actual_resource_type == le_coll)) {
+ return collection;
+ } else {
+ return (oci_collection *) NULL;
+ }
}
/* }}} */
@@ -4598,23 +4727,23 @@
PHP_FUNCTION(ocifreecollection)
{
- zval *id;
- int inx;
- oci_collection *coll;
- oci_connection *connection;
-
- if ((id = getThis()) != 0) {
- inx = _oci_get_ocicoll(id,&coll TSRMLS_CC);
- if (inx) {
+ zval *id;
+ int inx;
+ oci_collection *coll;
+ oci_connection *connection;
+
+ if ((id = getThis()) != 0) {
+ inx = _oci_get_ocicoll(id,&coll TSRMLS_CC);
+ if (inx) {
/*
* Do we need to free the object?
*
*/
connection = coll->conn;
- oci_debug("OCIfreecollection: coll=%d",inx);
+ oci_debug("OCIfreecollection: coll=%d",inx);
CALL_OCI_RETURN(connection->error, OCIObjectFree(
- OCI(pEnv),
+ connection->session->pEnv,
connection->pError,
(dvoid *)coll->coll,
(ub2)(OCI_OBJECTFREE_FORCE)));
@@ -4624,10 +4753,10 @@
RETURN_FALSE;
}
- zend_list_delete(inx);
- RETURN_TRUE;
- }
- }
+ zend_list_delete(inx);
+ RETURN_TRUE;
+ }
+ }
RETURN_FALSE;
}
@@ -4638,26 +4767,26 @@
PHP_FUNCTION(ocicollappend)
{
- zval *id, **arg;
- oci_connection *connection;
- oci_collection *coll;
- OCINumber num;
+ zval *id, **arg;
+ oci_connection *connection;
+ oci_collection *coll;
+ OCINumber num;
OCIString *ocistr = (OCIString *)0;
OCIInd new_ind = OCI_IND_NOTNULL;
OCIInd null_ind = OCI_IND_NULL;
OCIDate dt;
- int inx;
+ int inx;
double ndx;
- if ((id = getThis()) != 0) {
- if ((inx = _oci_get_ocicoll(id,&coll TSRMLS_CC)) == 0) {
- RETURN_FALSE;
- }
-
- connection = coll->conn;
- if (zend_get_parameters_ex(1, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
+ if ((id = getThis()) != 0) {
+ if ((inx = _oci_get_ocicoll(id,&coll TSRMLS_CC)) == 0) {
+ RETURN_FALSE;
+ }
+
+ connection = coll->conn;
+ if (zend_get_parameters_ex(1, &arg) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
/*
* Handle NULLS. For consistency with the rest of the OCI8 library,
when
@@ -4666,7 +4795,7 @@
convert_to_string_ex(arg);
if(Z_STRLEN_PP(arg) == 0) {
CALL_OCI_RETURN(connection->error, OCICollAppend(
- OCI(pEnv),
+ connection->session->pEnv,
connection->pError,
(dword *)0,
&null_ind,
@@ -4680,98 +4809,98 @@
}
switch(coll->element_typecode) {
- case OCI_TYPECODE_DATE:
- convert_to_string_ex(arg);
+ case OCI_TYPECODE_DATE:
+ convert_to_string_ex(arg);
+
+ CALL_OCI_RETURN(connection->error, OCIDateFromText(
+ connection->pError,
+ Z_STRVAL_PP(arg),
+ Z_STRLEN_PP(arg),
+ 0,
+ 0,
+ 0,
+ 0,
+ &dt));
+
+ if (connection->error) {
+ oci_error(connection->pError,
+"OCIDateFromText", connection->error);
+ RETURN_FALSE;
+ }
+
+ CALL_OCI_RETURN(connection->error, OCICollAppend(
+ connection->session->pEnv,
+ connection->pError,
+ (dvoid *) &dt,
+ (dvoid *) &new_ind,
+ (OCIColl *) coll->coll));
+
+ if (connection->error) {
+ oci_error(connection->pError, "OCICollAppend",
+connection->error);
+ RETURN_FALSE;
+ }
+ RETURN_TRUE;
+ break;
+ case OCI_TYPECODE_VARCHAR2 :
+ convert_to_string_ex(arg);
+
+ CALL_OCI_RETURN(connection->error, OCIStringAssignText(
+ connection->session->pEnv,
+ connection->pError,
+ Z_STRVAL_PP(arg),
+ Z_STRLEN_PP(arg),
+ &ocistr));
+
+ if (connection->error) {
+ oci_error(connection->pError,
+"OCIStringAssignText", connection->error);
+ RETURN_FALSE;
+ }
+
+ CALL_OCI_RETURN(connection->error, OCICollAppend(
+ connection->session->pEnv,
+ connection->pError,
+ (dvoid *) ocistr,
+ (dvoid *) &new_ind,
+ (OCIColl *) coll->coll));
+
+ if (connection->error) {
+ oci_error(connection->pError, "OCICollAppend",
+connection->error);
+ RETURN_FALSE;
+ }
+ RETURN_TRUE;
+ break;
+ case OCI_TYPECODE_UNSIGNED16 : /*
+UNSIGNED SHORT */
+ case OCI_TYPECODE_UNSIGNED32 : /*
+UNSIGNED LONG */
+ case OCI_TYPECODE_REAL :
+/* REAL */
+ case OCI_TYPECODE_DOUBLE :
+/* DOUBLE */
+ case OCI_TYPECODE_INTEGER :
+ /* INT */
+ case OCI_TYPECODE_SIGNED16 :
+/* SHORT */
+ case OCI_TYPECODE_SIGNED32 :
+/* LONG */
+ case OCI_TYPECODE_DECIMAL : /*
+DECIMAL */
+ case OCI_TYPECODE_FLOAT : /*
+FLOAT */
+ case OCI_TYPECODE_NUMBER : /*
+NUMBER */
+ case OCI_TYPECODE_SMALLINT : /*
+SMALLINT */
+ convert_to_double_ex(arg);
+ ndx = (double)Z_DVAL_PP(arg);
+
+ CALL_OCI_RETURN(connection->error, OCINumberFromReal(
+ connection->pError,
+ &ndx,
+ sizeof(double),&num));
+
+ if (connection->error) {
+ oci_error(connection->pError,
+"OCINumberFromReal", connection->error);
+ RETURN_FALSE;
+ }
- CALL_OCI_RETURN(connection->error, OCIDateFromText(
- connection->pError,
- Z_STRVAL_PP(arg),
- Z_STRLEN_PP(arg),
- 0,
- 0,
- 0,
- 0,
- &dt));
-
- if (connection->error) {
- oci_error(connection->pError, "OCIDateFromText",
connection->error);
- RETURN_FALSE;
- }
-
- CALL_OCI_RETURN(connection->error, OCICollAppend(
- OCI(pEnv),
- connection->pError,
- (dvoid *) &dt,
- (dvoid *) &new_ind,
- (OCIColl *) coll->coll));
-
- if (connection->error) {
- oci_error(connection->pError, "OCICollAppend",
connection->error);
- RETURN_FALSE;
- }
- RETURN_TRUE;
- break;
- case OCI_TYPECODE_VARCHAR2 :
- convert_to_string_ex(arg);
-
- CALL_OCI_RETURN(connection->error, OCIStringAssignText(
- OCI(pEnv),
- connection->pError,
- Z_STRVAL_PP(arg),
- Z_STRLEN_PP(arg),
- &ocistr));
-
- if (connection->error) {
- oci_error(connection->pError,
"OCIStringAssignText", connection->error);
- RETURN_FALSE;
- }
-
- CALL_OCI_RETURN(connection->error, OCICollAppend(
- OCI(pEnv),
- connection->pError,
- (dvoid *) ocistr,
- (dvoid *) &new_ind,
- (OCIColl *) coll->coll));
-
- if (connection->error) {
- oci_error(connection->pError, "OCICollAppend",
connection->error);
- RETURN_FALSE;
- }
- RETURN_TRUE;
- break;
- case OCI_TYPECODE_UNSIGNED16 : /* UNSIGNED
SHORT */
- case OCI_TYPECODE_UNSIGNED32 : /* UNSIGNED
LONG */
- case OCI_TYPECODE_REAL : /*
REAL */
- case OCI_TYPECODE_DOUBLE : /*
DOUBLE */
- case OCI_TYPECODE_INTEGER : /*
INT */
- case OCI_TYPECODE_SIGNED16 : /*
SHORT */
- case OCI_TYPECODE_SIGNED32 : /*
LONG */
- case OCI_TYPECODE_DECIMAL : /*
DECIMAL */
- case OCI_TYPECODE_FLOAT : /*
FLOAT */
- case OCI_TYPECODE_NUMBER : /*
NUMBER */
- case OCI_TYPECODE_SMALLINT : /*
SMALLINT */
- convert_to_double_ex(arg);
- ndx = (double)Z_DVAL_PP(arg);
-
- CALL_OCI_RETURN(connection->error, OCINumberFromReal(
- connection->pError,
- &ndx,
- sizeof(double),&num));
-
- if (connection->error) {
- oci_error(connection->pError, "OCINumberFromReal",
connection->error);
- RETURN_FALSE;
- }
-
- CALL_OCI_RETURN(connection->error, OCICollAppend(
- OCI(pEnv),
- connection->pError,
- (dvoid *) &num,
- (dvoid *) &new_ind,
- (OCIColl *) coll->coll));
+ CALL_OCI_RETURN(connection->error, OCICollAppend(
+ connection->session->pEnv,
+ connection->pError,
+ (dvoid *) &num,
+ (dvoid *) &new_ind,
+ (OCIColl *) coll->coll));
- RETURN_TRUE;
- break;
+ RETURN_TRUE;
+ break;
}
}
@@ -4784,7 +4913,7 @@
PHP_FUNCTION(ocicollgetelem)
{
- zval *id,**arg;
+ zval *id,**arg;
oci_connection *connection;
oci_collection *coll;
ub4 ndx;
@@ -4812,7 +4941,7 @@
connection = coll->conn;
CALL_OCI_RETURN(connection->error, OCICollGetElem(
- OCI(pEnv),
+ connection->session->pEnv,
connection->pError,
coll->coll,
ndx,
@@ -4827,7 +4956,7 @@
/* Return false if value does not exist at that location */
if(exists == 0) {
- php_error(E_WARNING, "OCICollGetElem - Invalid index %d", ndx);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "OCICollGetElem -
+Invalid index %d", ndx);
RETURN_FALSE;
}
@@ -4837,47 +4966,47 @@
}
switch (coll->element_typecode) {
- case OCI_TYPECODE_DATE:
- len = 1024;
- CALL_OCI(OCIDateToText(
- connection->pError,
- elem,
- 0, /* fmt */
- 0, /* fmt_length */
- 0, /* lang_name */
- 0, /* lang_length */
- &len,
- buff));
-
- RETURN_STRINGL(buff,len,1);
- case OCI_TYPECODE_VARCHAR2 :
- ocistr = *(OCIString **)elem;
- str = OCIStringPtr(OCI(pEnv),ocistr); /* XXX not protected
against recursion! */
- RETURN_STRINGL(str,strlen(str),1);
- break;
- case OCI_TYPECODE_UNSIGNED16 : /* UNSIGNED
SHORT */
- case OCI_TYPECODE_UNSIGNED32 : /* UNSIGNED
LONG */
- case OCI_TYPECODE_REAL : /* REAL */
- case OCI_TYPECODE_DOUBLE : /* DOUBLE */
- case OCI_TYPECODE_INTEGER : /* INT */
- case OCI_TYPECODE_SIGNED16 : /* SHORT */
- case OCI_TYPECODE_SIGNED32 : /* LONG */
- case OCI_TYPECODE_DECIMAL : /* DECIMAL */
- case OCI_TYPECODE_FLOAT : /* FLOAT */
- case OCI_TYPECODE_NUMBER : /* NUMBER */
- case OCI_TYPECODE_SMALLINT : /* SMALLINT */
- CALL_OCI_RETURN(connection->error, OCINumberToReal(
- connection->pError,
- (CONST OCINumber *) elem,
- (uword) sizeof(dnum),
- (dvoid *) &dnum));
-
- if (connection->error) {
- oci_error(connection->pError, "OCINumberToReal",
connection->error);
- RETURN_FALSE;
- }
- RETURN_DOUBLE(dnum);
- break;
+ case OCI_TYPECODE_DATE:
+ len = 1024;
+ CALL_OCI(OCIDateToText(
+ connection->pError,
+ elem,
+ 0, /* fmt */
+ 0, /* fmt_length */
+ 0, /* lang_name */
+ 0, /* lang_length */
+ &len,
+ buff));
+
+ RETURN_STRINGL(buff,len,1);
+ case OCI_TYPECODE_VARCHAR2 :
+ ocistr = *(OCIString **)elem;
+ str = OCIStringPtr(connection->session->pEnv,ocistr);
+/* XXX not protected against recursion! */
+ RETURN_STRINGL(str,strlen(str),1);
+ break;
+ case OCI_TYPECODE_UNSIGNED16 : /*
+UNSIGNED SHORT */
+ case OCI_TYPECODE_UNSIGNED32 : /*
+UNSIGNED LONG */
+ case OCI_TYPECODE_REAL : /* REAL
+ */
+ case OCI_TYPECODE_DOUBLE : /* DOUBLE
+ */
+ case OCI_TYPECODE_INTEGER : /* INT */
+ case OCI_TYPECODE_SIGNED16 : /* SHORT
+*/
+ case OCI_TYPECODE_SIGNED32 : /* LONG
+*/
+ case OCI_TYPECODE_DECIMAL : /*
+DECIMAL */
+ case OCI_TYPECODE_FLOAT : /* FLOAT
+ */
+ case OCI_TYPECODE_NUMBER : /* NUMBER
+ */
+ case OCI_TYPECODE_SMALLINT : /*
+SMALLINT */
+ CALL_OCI_RETURN(connection->error, OCINumberToReal(
+ connection->pError,
+ (CONST OCINumber *) elem,
+ (uword) sizeof(dnum),
+ (dvoid *) &dnum));
+
+ if (connection->error) {
+ oci_error(connection->pError,
+"OCINumberToReal", connection->error);
+ RETURN_FALSE;
+ }
+ RETURN_DOUBLE(dnum);
+ break;
}
}
@@ -4911,7 +5040,7 @@
connection = coll->conn;
CALL_OCI_RETURN(connection->error, OCICollAssign(
- OCI(pEnv),
+ connection->session->pEnv,
connection->pError,
from_coll->coll,
coll->coll));
@@ -4957,7 +5086,7 @@
ndx = Z_LVAL_PP(index);
connection = coll->conn;
-
+
if (connection->error) {
oci_error(connection->pError, "OCICollAssignElem",
connection->error);
RETURN_FALSE;
@@ -4971,7 +5100,7 @@
if(Z_STRLEN_PP(val) == 0) {
CALL_OCI_RETURN(connection->error, OCICollAssignElem(
- OCI(pEnv),
+ connection->session->pEnv,
connection->pError,
ndx,
(dword *)0,
@@ -4986,104 +5115,104 @@
}
switch(coll->element_typecode) {
- case OCI_TYPECODE_DATE:
- convert_to_string_ex(val);
- CALL_OCI_RETURN(connection->error, OCIDateFromText(
- connection->pError,
- Z_STRVAL_PP(val),
- Z_STRLEN_PP(val),
- 0,
- 0,
- 0,
- 0,
- &dt));
-
- if (connection->error) {
- oci_error(connection->pError, "OCIDateFromText",
connection->error);
- RETURN_FALSE;
- }
-
- CALL_OCI_RETURN(connection->error, OCICollAssignElem(
- OCI(pEnv),
- connection->pError,
- ndx,
- (dword *)&dt,
- &new_ind,
- coll->coll));
-
- if (connection->error) {
- oci_error(connection->pError, "OCICollAssignElem",
connection->error);
- RETURN_FALSE;
- }
- break;
- case OCI_TYPECODE_VARCHAR2 :
- convert_to_string_ex(val);
-
- CALL_OCI_RETURN(connection->error, OCIStringAssignText(
- OCI(pEnv),
- connection->pError,
- Z_STRVAL_PP(val),
- Z_STRLEN_PP(val),
- &ocistr));
-
- if (connection->error) {
- oci_error(connection->pError,
"OCIStringAssignText", connection->error);
- RETURN_FALSE;
- }
-
- CALL_OCI_RETURN(connection->error, OCICollAssignElem(
- OCI(pEnv),
- connection->pError,
- ndx,
- (dword *)ocistr,
- &new_ind,
- coll->coll));
-
- if (connection->error) {
- oci_error(connection->pError, "OCICollAssignElem",
connection->error);
- RETURN_FALSE;
- }
- RETURN_TRUE;
- break;
- case OCI_TYPECODE_UNSIGNED16 : /* UNSIGNED
SHORT */
- case OCI_TYPECODE_UNSIGNED32 : /* UNSIGNED
LONG */
- case OCI_TYPECODE_REAL : /* REAL */
- case OCI_TYPECODE_DOUBLE : /* DOUBLE */
- case OCI_TYPECODE_INTEGER : /* INT */
- case OCI_TYPECODE_SIGNED16 : /* SHORT */
- case OCI_TYPECODE_SIGNED32 : /* LONG */
- case OCI_TYPECODE_DECIMAL : /* DECIMAL */
- case OCI_TYPECODE_FLOAT : /* FLOAT */
- case OCI_TYPECODE_NUMBER : /* NUMBER */
- case OCI_TYPECODE_SMALLINT : /* SMALLINT */
- convert_to_double_ex(val);
- dnum = (double)Z_DVAL_PP(val);
-
- CALL_OCI_RETURN(connection->error, OCINumberFromReal(
- connection->pError,
- &dnum,
- sizeof(double),
- &num));
-
- if (connection->error) {
- oci_error(connection->pError, "OCINumberFromReal",
connection->error);
- RETURN_FALSE;
- }
-
- CALL_OCI_RETURN(connection->error, OCICollAssignElem(
- OCI(pEnv),
- connection->pError,
- ndx,
- (dword *)&num,
- &new_ind,
- coll->coll));
-
- if (connection->error) {
- oci_error(connection->pError, "OCICollAssignElem",
connection->error);
- RETURN_FALSE;
- }
- RETURN_TRUE;
- break;
+ case OCI_TYPECODE_DATE:
+ convert_to_string_ex(val);
+ CALL_OCI_RETURN(connection->error, OCIDateFromText(
+ connection->pError,
+ Z_STRVAL_PP(val),
+ Z_STRLEN_PP(val),
+ 0,
+ 0,
+ 0,
+ 0,
+ &dt));
+
+ if (connection->error) {
+ oci_error(connection->pError,
+"OCIDateFromText", connection->error);
+ RETURN_FALSE;
+ }
+
+ CALL_OCI_RETURN(connection->error, OCICollAssignElem(
+ connection->session->pEnv,
+ connection->pError,
+ ndx,
+ (dword *)&dt,
+ &new_ind,
+ coll->coll));
+
+ if (connection->error) {
+ oci_error(connection->pError,
+"OCICollAssignElem", connection->error);
+ RETURN_FALSE;
+ }
+ break;
+ case OCI_TYPECODE_VARCHAR2 :
+ convert_to_string_ex(val);
+
+ CALL_OCI_RETURN(connection->error, OCIStringAssignText(
+ connection->session->pEnv,
+ connection->pError,
+ Z_STRVAL_PP(val),
+ Z_STRLEN_PP(val),
+ &ocistr));
+
+ if (connection->error) {
+ oci_error(connection->pError,
+"OCIStringAssignText", connection->error);
+ RETURN_FALSE;
+ }
+
+ CALL_OCI_RETURN(connection->error, OCICollAssignElem(
+ connection->session->pEnv,
+ connection->pError,
+ ndx,
+ (dword *)ocistr,
+ &new_ind,
+ coll->coll));
+
+ if (connection->error) {
+ oci_error(connection->pError,
+"OCICollAssignElem", connection->error);
+ RETURN_FALSE;
+ }
+ RETURN_TRUE;
+ break;
+ case OCI_TYPECODE_UNSIGNED16 : /*
+UNSIGNED SHORT */
+ case OCI_TYPECODE_UNSIGNED32 : /*
+UNSIGNED LONG */
+ case OCI_TYPECODE_REAL : /* REAL
+ */
+ case OCI_TYPECODE_DOUBLE : /* DOUBLE
+ */
+ case OCI_TYPECODE_INTEGER : /* INT */
+ case OCI_TYPECODE_SIGNED16 : /* SHORT
+*/
+ case OCI_TYPECODE_SIGNED32 : /* LONG
+*/
+ case OCI_TYPECODE_DECIMAL : /*
+DECIMAL */
+ case OCI_TYPECODE_FLOAT : /* FLOAT
+ */
+ case OCI_TYPECODE_NUMBER : /* NUMBER
+ */
+ case OCI_TYPECODE_SMALLINT : /*
+SMALLINT */
+ convert_to_double_ex(val);
+ dnum = (double)Z_DVAL_PP(val);
+
+ CALL_OCI_RETURN(connection->error, OCINumberFromReal(
+ connection->pError,
+ &dnum,
+ sizeof(double),
+ &num));
+
+ if (connection->error) {
+ oci_error(connection->pError,
+"OCINumberFromReal", connection->error);
+ RETURN_FALSE;
+ }
+
+ CALL_OCI_RETURN(connection->error, OCICollAssignElem(
+ connection->session->pEnv,
+ connection->pError,
+ ndx,
+ (dword *)&num,
+ &new_ind,
+ coll->coll));
+
+ if (connection->error) {
+ oci_error(connection->pError,
+"OCICollAssignElem", connection->error);
+ RETURN_FALSE;
+ }
+ RETURN_TRUE;
+ break;
}
}
RETURN_FALSE;
@@ -5108,7 +5237,7 @@
connection = coll->conn;
CALL_OCI_RETURN(connection->error, OCICollSize(
- OCI(pEnv),
+ connection->session->pEnv,
coll->conn->pError,
coll->coll,
&sz));
@@ -5185,19 +5314,19 @@
PHP_FUNCTION(ocinewcollection)
{
- dvoid *dschp1;
- dvoid *parmp1;
- dvoid *parmp2;
- zval **conn, **tdo, **schema;
- oci_connection *connection;
- oci_collection *coll;
+ dvoid *dschp1;
+ dvoid *parmp1;
+ dvoid *parmp2;
+ zval **conn, **tdo, **schema;
+ oci_connection *connection;
+ oci_collection *coll;
int ac = ZEND_NUM_ARGS();
- if (ac < 2 || ac > 3 || zend_get_parameters_ex(ac, &conn, &tdo, &schema) ==
FAILURE) {
- WRONG_PARAM_COUNT;
- }
+ if (ac < 2 || ac > 3 || zend_get_parameters_ex(ac, &conn, &tdo, &schema) ==
+FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
- convert_to_string_ex(tdo);
+ convert_to_string_ex(tdo);
if(ac == 3) {
convert_to_string_ex(schema);
@@ -5212,7 +5341,7 @@
zend_list_addref(connection->id);
CALL_OCI_RETURN(connection->error, OCITypeByName(
- OCI(pEnv),
+ connection->session->pEnv,
connection->pError,
connection->pServiceContext,
ac==3?(text *)Z_STRVAL_PP(schema):(text *)0,
@@ -5225,22 +5354,22 @@
OCI_TYPEGET_ALL,
&(coll->tdo)));
- if (connection->error) {
- oci_error(connection->pError, "OCITypeByName", connection->error);
- RETURN_FALSE;
- }
+ if (connection->error) {
+ oci_error(connection->pError, "OCITypeByName", connection->error);
+ RETURN_FALSE;
+ }
CALL_OCI_RETURN(connection->error, OCIHandleAlloc(
- OCI(pEnv),
+ connection->session->pEnv,
(dvoid **) &dschp1,
(ub4) OCI_HTYPE_DESCRIBE,
(size_t) 0,
(dvoid **) 0));
- if (connection->error) {
- oci_error(connection->pError, "OCI_HTYPE_DESCRIBE", connection->error);
- RETURN_FALSE;
- }
+ if (connection->error) {
+ oci_error(connection->pError, "OCI_HTYPE_DESCRIBE", connection->error);
+ RETURN_FALSE;
+ }
CALL_OCI_RETURN(connection->error, OCIDescribeAny(
connection->pServiceContext,
@@ -5252,10 +5381,10 @@
(ub1) OCI_PTYPE_TYPE,
dschp1));
- if (connection->error) {
- oci_error(connection->pError, "OCI_OTYPE_PTR", connection->error);
- RETURN_FALSE;
- }
+ if (connection->error) {
+ oci_error(connection->pError, "OCI_OTYPE_PTR", connection->error);
+ RETURN_FALSE;
+ }
CALL_OCI_RETURN(connection->error, OCIAttrGet(
(dvoid *) dschp1,
@@ -5265,10 +5394,10 @@
(ub4)OCI_ATTR_PARAM,
connection->pError));
- if (connection->error) {
- oci_error(connection->pError, "OCI_ATTR_PARAM", connection->error);
- RETURN_FALSE;
- }
+ if (connection->error) {
+ oci_error(connection->pError, "OCI_ATTR_PARAM", connection->error);
+ RETURN_FALSE;
+ }
/* get the collection type code of the attribute */
@@ -5280,74 +5409,74 @@
(ub4) OCI_ATTR_COLLECTION_TYPECODE,
connection->pError));
- if (connection->error) {
- oci_error(connection->pError, "OCI_ATTR_COLLECTION_TYPECODE",
connection->error);
- RETURN_FALSE;
- }
+ if (connection->error) {
+ oci_error(connection->pError, "OCI_ATTR_COLLECTION_TYPECODE",
+connection->error);
+ RETURN_FALSE;
+ }
switch(coll->coll_typecode) {
- case OCI_TYPECODE_TABLE:
- case OCI_TYPECODE_VARRAY:
- CALL_OCI_RETURN(connection->error, OCIAttrGet(
- (dvoid*) parmp1,
- (ub4) OCI_DTYPE_PARAM,
- (dvoid*) &parmp2,
- (ub4 *) 0,
- (ub4) OCI_ATTR_COLLECTION_ELEMENT,
- connection->pError));
-
- if (connection->error) {
- oci_error(connection->pError,
"OCI_ATTR_COLLECTION_ELEMENT", connection->error);
- RETURN_FALSE;
- }
-
- CALL_OCI_RETURN(connection->error, OCIAttrGet(
- (dvoid*) parmp2,
- (ub4) OCI_DTYPE_PARAM,
- (dvoid*) &(coll->elem_ref),
- (ub4 *) 0,
- (ub4) OCI_ATTR_REF_TDO,
- connection->pError));
-
- if (connection->error) {
- oci_error(connection->pError, "OCI_ATTR_REF_TDO",
connection->error);
- RETURN_FALSE;
- }
-
- CALL_OCI_RETURN(connection->error, OCITypeByRef(
- OCI(pEnv),
- connection->pError,
- coll->elem_ref,
- OCI_DURATION_SESSION,
- OCI_TYPEGET_HEADER,
- &(coll->element_type)));
-
- if (connection->error) {
- oci_error(connection->pError, "OCI_TYPEGET_HEADER",
connection->error);
- RETURN_FALSE;
- }
-
- CALL_OCI_RETURN(connection->error, OCIAttrGet(
- (dvoid*) parmp2,
- (ub4) OCI_DTYPE_PARAM,
- (dvoid*) &(coll->element_typecode),
- (ub4 *) 0,
- (ub4) OCI_ATTR_TYPECODE,
- connection->pError));
-
- if (connection->error) {
- oci_error(connection->pError, "OCI_ATTR_TYPECODE",
connection->error);
- RETURN_FALSE;
- }
- break;
- default:
- php_error(E_WARNING, "OCINewCollection - Unknown Type %d",
coll->coll_typecode);
- break;
- }
+ case OCI_TYPECODE_TABLE:
+ case OCI_TYPECODE_VARRAY:
+ CALL_OCI_RETURN(connection->error, OCIAttrGet(
+ (dvoid*) parmp1,
+ (ub4) OCI_DTYPE_PARAM,
+ (dvoid*) &parmp2,
+ (ub4 *) 0,
+ (ub4) OCI_ATTR_COLLECTION_ELEMENT,
+ connection->pError));
+
+ if (connection->error) {
+ oci_error(connection->pError,
+"OCI_ATTR_COLLECTION_ELEMENT", connection->error);
+ RETURN_FALSE;
+ }
+
+ CALL_OCI_RETURN(connection->error, OCIAttrGet(
+ (dvoid*) parmp2,
+ (ub4) OCI_DTYPE_PARAM,
+ (dvoid*) &(coll->elem_ref),
+ (ub4 *) 0,
+ (ub4) OCI_ATTR_REF_TDO,
+ connection->pError));
+
+ if (connection->error) {
+ oci_error(connection->pError, "OCI_ATTR_REF_TDO",
+connection->error);
+ RETURN_FALSE;
+ }
+
+ CALL_OCI_RETURN(connection->error, OCITypeByRef(
+ connection->session->pEnv,
+ connection->pError,
+ coll->elem_ref,
+ OCI_DURATION_SESSION,
+ OCI_TYPEGET_HEADER,
+ &(coll->element_type)));
+
+ if (connection->error) {
+ oci_error(connection->pError, "OCI_TYPEGET_HEADER",
+connection->error);
+ RETURN_FALSE;
+ }
+
+ CALL_OCI_RETURN(connection->error, OCIAttrGet(
+ (dvoid*) parmp2,
+ (ub4) OCI_DTYPE_PARAM,
+ (dvoid*) &(coll->element_typecode),
+ (ub4 *) 0,
+ (ub4) OCI_ATTR_TYPECODE,
+ connection->pError));
+
+ if (connection->error) {
+ oci_error(connection->pError, "OCI_ATTR_TYPECODE",
+connection->error);
+ RETURN_FALSE;
+ }
+ break;
+ default:
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "OCINewCollection
+- Unknown Type %d", coll->coll_typecode);
+ break;
+ }
/* Create object to hold return table */
CALL_OCI_RETURN(connection->error, OCIObjectNew(
- OCI(pEnv),
+ connection->session->pEnv,
connection->pError,
connection->pServiceContext,
OCI_TYPECODE_TABLE,
@@ -5362,8 +5491,8 @@
RETURN_FALSE;
}
- object_init_ex(return_value, oci_coll_class_entry_ptr);
- add_property_resource(return_value, "collection",coll->id);
+ object_init_ex(return_value, oci_coll_class_entry_ptr);
+ add_property_resource(return_value, "collection",coll->id);
}
/* }}} */
Index: php4/ext/oci8/php_oci8.h
diff -u php4/ext/oci8/php_oci8.h:1.24.2.1 php4/ext/oci8/php_oci8.h:1.24.2.2
--- php4/ext/oci8/php_oci8.h:1.24.2.1 Tue Dec 31 11:35:04 2002
+++ php4/ext/oci8/php_oci8.h Fri Jan 31 09:21:19 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_oci8.h,v 1.24.2.1 2002/12/31 16:35:04 sebastian Exp $ */
+/* $Id: php_oci8.h,v 1.24.2.2 2003/01/31 14:21:19 sniper Exp $ */
#if HAVE_OCI8
# ifndef PHP_OCI8_H
@@ -70,6 +70,8 @@
char *hashed_details;
oci_server *server;
OCISession *pSession;
+ OCIEnv *pEnv; /* sessions own environment */
+ ub2 charsetId; /* sessions used character set (mostly
+this will be 0, so NLS_LANG will be used. */
} oci_session;
typedef struct {
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php