Browse Source

Added Oracle (oci8) support

@Added Oracle (oci8) support to dbx module (Mc)
experimental/threaded
Marc Boeren 24 years ago
parent
commit
4448c3f69f
  1. 10
      ext/dbx/dbx.c
  2. 47
      ext/dbx/dbx_oci8.c
  3. 2
      ext/dbx/howto_extend_dbx.html

10
ext/dbx/dbx.c

@ -213,7 +213,7 @@ ZEND_MINFO_FUNCTION(dbx)
php_info_print_table_start();
php_info_print_table_row(2, "dbx support", "enabled");
php_info_print_table_row(2, "dbx version", "1.0.0");
php_info_print_table_row(2, "supported databases", "MySQL\nODBC\nPostgreSQL\nMicrosoft SQL Server\nFrontBase\nOracle 8 (not really)\nSybase-CT");
php_info_print_table_row(2, "supported databases", "MySQL\nODBC\nPostgreSQL\nMicrosoft SQL Server\nFrontBase\nOracle 8 (oci8)\nSybase-CT");
php_info_print_table_end();
}
@ -673,8 +673,7 @@ int switch_dbx_connect(zval **rv, zval **host, zval **db, zval **username, zval
case DBX_PGSQL: return dbx_pgsql_connect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);
case DBX_MSSQL: return dbx_mssql_connect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);
case DBX_FBSQL: return dbx_fbsql_connect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);
case DBX_OCI8: zend_error(E_WARNING, "dbx_connect: OCI8 extension is still highly experimental!");
return dbx_oci8_connect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);
case DBX_OCI8: return dbx_oci8_connect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);
case DBX_SYBASECT: return dbx_sybasect_connect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
zend_error(E_WARNING, "dbx_connect: not supported in this module");
@ -690,8 +689,7 @@ int switch_dbx_pconnect(zval **rv, zval **host, zval **db, zval **username, zval
case DBX_PGSQL: return dbx_pgsql_pconnect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);
case DBX_MSSQL: return dbx_mssql_pconnect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);
case DBX_FBSQL: return dbx_fbsql_pconnect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);
case DBX_OCI8: zend_error(E_WARNING, "dbx_pconnect: OCI8 extension is still highly experimental!");
return dbx_oci8_pconnect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);
case DBX_OCI8: return dbx_oci8_pconnect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);
case DBX_SYBASECT: return dbx_sybasect_pconnect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
zend_error(E_WARNING, "dbx_pconnect: not supported in this module");
@ -803,7 +801,7 @@ int switch_dbx_error(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS,
case DBX_PGSQL: return dbx_pgsql_error(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);
case DBX_MSSQL: return dbx_mssql_error(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);
case DBX_FBSQL: return dbx_fbsql_error(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);
case DBX_OCI8: return dbx_oci8_error(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);
/* case DBX_OCI8: return dbx_oci8_error(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU); */
case DBX_SYBASECT: return dbx_sybasect_error(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
zend_error(E_WARNING, "dbx_error: not supported in this module");

47
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;

2
ext/dbx/howto_extend_dbx.html

@ -50,7 +50,7 @@ a { color: #000088; }
How-to code support for another database<br>
</div>
<div class="text">
Every supported database module must be loaded by PHP before it can be used. Every supported database module must be added to the dbx-module before it can be used. Currently there is support for MySQL, PostgreSQL, Microsoft SQL Server, Frontbase, Sybase-CT and ODBC, but it is not difficult to add support for more databases.<br>
Every supported database module must be loaded by PHP before it can be used. Every supported database module must be added to the dbx-module before it can be used. Currently there is support for MySQL, PostgreSQL, Microsoft SQL Server, Frontbase, Sybase-CT, Oracle (oci8) and ODBC. It is not difficult to add support for more databases.<br>
<br>
The dbx module is found in de PHP ext/dbx folder. The support-code is found in the same folder <br>
<br>

Loading…
Cancel
Save