diff options
author | Marc Boeren <mboeren@php.net> | 2002-10-23 10:50:22 +0000 |
---|---|---|
committer | Marc Boeren <mboeren@php.net> | 2002-10-23 10:50:22 +0000 |
commit | 4448c3f69f8c4dff2c9fda3978896fe02ab2a361 (patch) | |
tree | 97c6012cadb02b21050258186af5c1ebb18e5708 /ext/dbx/dbx_oci8.c | |
parent | 1b50e476482cfa6a38aed8b5a1eb6913c78c3cb6 (diff) | |
download | php-git-4448c3f69f8c4dff2c9fda3978896fe02ab2a361.tar.gz |
Added Oracle (oci8) support
@Added Oracle (oci8) support to dbx module (Mc)
Diffstat (limited to 'ext/dbx/dbx_oci8.c')
-rw-r--r-- | ext/dbx/dbx_oci8.c | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/ext/dbx/dbx_oci8.c b/ext/dbx/dbx_oci8.c index 4ee58e0e77..eb4c10c85e 100644 --- a/ext/dbx/dbx_oci8.c +++ b/ext/dbx/dbx_oci8.c @@ -71,6 +71,8 @@ int dbx_oci8_pconnect(zval **rv, zval **host, zval **db, zval **username, zval * int dbx_oci8_close(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS) { /* returns 1 as long on success or 0 as long on failure */ + /* actually, ocilogoff officially does nothing, so what should I return? */ + /* I will just return NULL right now and change the test accordingly */ int number_of_arguments=1; zval **arguments[1]; zval *returned_zval=NULL; @@ -87,11 +89,12 @@ int dbx_oci8_close(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS) int dbx_oci8_query(zval **rv, zval **dbx_handle, zval **db_name, zval **sql_statement, INTERNAL_FUNCTION_PARAMETERS) { - /* returns 1 as long or a result identifier as resource on success or 0 as long on failure */ + /* returns 1 as long or a result identifier as resource on success or 0 as long on failure */ int number_of_arguments=2; zval **arguments[2]; zval *returned_zval=NULL; zval *execute_zval=NULL; + zval *statementtype_zval=NULL; arguments[0]=dbx_handle; arguments[1]=sql_statement; @@ -104,13 +107,36 @@ int dbx_oci8_query(zval **rv, zval **dbx_handle, zval **db_name, zval **sql_stat number_of_arguments=1; arguments[0]=&returned_zval; dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "OCIExecute", &execute_zval, number_of_arguments, arguments); - /* OCIExecute returns a bool for success or failure???? */ - if (!execute_zval || Z_TYPE_P(execute_zval)!=IS_BOOL) { + /* OCIExecute returns a bool for success or failure */ + if (!execute_zval || Z_TYPE_P(execute_zval)!=IS_BOOL || Z_BVAL_P(execute_zval)==FALSE) { if (execute_zval) zval_ptr_dtor(&execute_zval); zval_ptr_dtor(&returned_zval); return 0; } - MOVE_RETURNED_TO_RV(rv, returned_zval); + number_of_arguments=1; + arguments[0]=&returned_zval; + dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "OCIStatementType", &statementtype_zval, number_of_arguments, arguments); + /* OCIStatementType returns a string. 'SELECT' means there are results */ + if (!statementtype_zval || Z_TYPE_P(statementtype_zval)!=IS_STRING) { + if (statementtype_zval) zval_ptr_dtor(&statementtype_zval); + if (execute_zval) zval_ptr_dtor(&execute_zval); + zval_ptr_dtor(&returned_zval); + return 0; + } + + if (!zend_binary_strcmp(Z_STRVAL_P(statementtype_zval), Z_STRLEN_P(statementtype_zval), "SELECT", sizeof("SELECT")-sizeof(""))) { + /* it is a select, so results are returned */ + MOVE_RETURNED_TO_RV(rv, returned_zval); + } else { + /* it is not a select, so just return success */ + zval_ptr_dtor(&returned_zval); + MAKE_STD_ZVAL(returned_zval); + ZVAL_BOOL(returned_zval, TRUE); + MOVE_RETURNED_TO_RV(rv, returned_zval); + } + if (statementtype_zval) zval_ptr_dtor(&statementtype_zval); + if (execute_zval) zval_ptr_dtor(&execute_zval); + return 1; } @@ -191,17 +217,19 @@ int dbx_oci8_getrow(zval **rv, zval **result_handle, long row_number, INTERNAL_F zval *zval_returned_array=NULL; zval *returned_zval=NULL; + MAKE_STD_ZVAL(zval_returned_array); /* no value needed, it will be overwritten anyway */ MAKE_STD_ZVAL(zval_resulttype); - ZVAL_LONG(zval_resulttype, OCI_NUM | OCI_RETURN_NULLS); /* no ASSOC, dbx handles that part */ + ZVAL_LONG(zval_resulttype, OCI_NUM | OCI_RETURN_NULLS | OCI_RETURN_LOBS); /* no ASSOC, dbx handles that part */ arguments[0]=result_handle; arguments[1]=&zval_returned_array; arguments[2]=&zval_resulttype; dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "OCIFetchInto", &returned_zval, number_of_arguments, arguments); - /* OCIFetchInto returns an integer, but the actual array is passed back in arg[1] */ - /* I'm not sure how this will work, Thies, so this is something that should be especially tested! */ - if (!returned_zval || Z_TYPE_P(returned_zval)!=IS_BOOL || Z_LVAL_P(returned_zval)==0) { + /* OCIFetchInto returns the number of columns as an integer on success and FALSE */ + /* on failure. The actual array is passed back in arg[1] */ + if (!returned_zval || Z_TYPE_P(returned_zval)!=IS_LONG || Z_LVAL_P(returned_zval)==0) { if (returned_zval) zval_ptr_dtor(&returned_zval); FREE_ZVAL(zval_resulttype); + FREE_ZVAL(zval_returned_array); return 0; } FREE_ZVAL(zval_resulttype); @@ -213,6 +241,9 @@ int dbx_oci8_getrow(zval **rv, zval **result_handle, long row_number, INTERNAL_F int dbx_oci8_error(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS) { /* returns string */ + /* OCIError needs a statement handle most of the times, and I can only provide */ + /* a db-handle which is only needed some of the time. For now, I have disabled */ + /* the dbx_error for the oci8 extension */ int number_of_arguments=1; zval **arguments[1]; zval *returned_zval=NULL; |