CVS update: php3/functions
| From: | ssb | Date: | Wed, 09 Sep 1998 18:33:22 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-890@lists.php.net to get a copy of this message | ||
Date: Wednesday September 9, 1998 @ 14:33
Author: ssb
Update of /repository/php3/functions
In directory asf:/u2/tmp/cvs-serv14091/functions
Modified Files:
oci8.c php3_oci8.h
Log Message:
more OCI8 work
Index: php3/functions/oci8.c
diff -c php3/functions/oci8.c:1.3 php3/functions/oci8.c:1.4
*** php3/functions/oci8.c:1.3 Wed Sep 9 08:38:08 1998
--- php3/functions/oci8.c Wed Sep 9 14:33:21 1998
***************
*** 23,36 ****
| If you did not, or have any questions about PHP licensing, please |
| contact core@php.net. |
+----------------------------------------------------------------------+
! | Authors: Stig Sæther Bakken <ssb@guardian.no> |
! | Mitch Golden <mgolden@interport.net> |
! | Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
! | Andreas Karajannis <Andreas.Karajannis@gmd.de> |
+----------------------------------------------------------------------+
*/
! /* $Id: oci8.c,v 1.3 1998/09/09 12:38:08 ssb Exp $ */
#include "php.h"
#include "internal_functions.h"
--- 23,33 ----
| If you did not, or have any questions about PHP licensing, please |
| contact core@php.net. |
+----------------------------------------------------------------------+
! | Authors: |
+----------------------------------------------------------------------+
*/
! /* $Id: oci8.c,v 1.4 1998/09/09 18:33:21 ssb Exp $ */
#include "php.h"
#include "internal_functions.h"
***************
*** 111,136 ****
void php3_info_oci8(void);
static ub4 php3i_oci8_error(OCIError *err_p, char *what, sword status);
! static int php3i_oci_ping(oci8_connection *conn);
static void OCI8_DEBUG(const char *format,...);
! static void php3i_oci_close_conn(oci8_connection *connection);
! static void php3i_oci_close_pconn(oci8_connection *connection);
/* }}} */
/* {{{ extension function prototypes */
! void php3_oci_logon(INTERNAL_FUNCTION_PARAMETERS);
! void php3_oci_debug(INTERNAL_FUNCTION_PARAMETERS);
/* }}} */
/* {{{ extension definition structures */
function_entry oci8_functions[] = {
! {"ocilogon", php3_oci_logon, NULL},
! {"ociplogon", php3_oci_plogon, NULL},
! {"ocidebug", php3_oci_debug, NULL},
! {NULL, NULL, NULL}
};
php3_module_entry oci8_module_entry = {
--- 108,146 ----
void php3_info_oci8(void);
static ub4 php3i_oci8_error(OCIError *err_p, char *what, sword status);
! static int php3i_oci8_ping(oci8_connection *conn);
static void OCI8_DEBUG(const char *format,...);
! static void php3i_oci8_close_conn(oci8_connection *connection);
! static void php3i_oci8_free_stmt(oci8_statement *statement);
! /*static void php3i_oci8_close_pconn(oci8_connection *connection);*/
/* }}} */
/* {{{ extension function prototypes */
! void php3_oci8_debug(INTERNAL_FUNCTION_PARAMETERS);
! void php3_oci8_logon(INTERNAL_FUNCTION_PARAMETERS);
! void php3_oci8_logoff(INTERNAL_FUNCTION_PARAMETERS);
! void php3_oci8_parse(INTERNAL_FUNCTION_PARAMETERS);
! void php3_oci8_execute(INTERNAL_FUNCTION_PARAMETERS);
! void php3_oci8_columnname(INTERNAL_FUNCTION_PARAMETERS);
! void php3_oci8_columnsize(INTERNAL_FUNCTION_PARAMETERS);
! void php3_oci8_columntype(INTERNAL_FUNCTION_PARAMETERS);
/* }}} */
/* {{{ extension definition structures */
function_entry oci8_functions[] = {
! {"ocilogon", php3_oci8_logon, NULL},
! /* {"ociplogon", php3_oci8_plogon, NULL},*/
! {"ocilogoff", php3_oci8_logoff, NULL},
! {"ocidebug", php3_oci8_debug, NULL},
! {"ociparse", php3_oci8_parse, NULL},
! {"ociexecute", php3_oci8_execute, NULL},
! {"ocicolumnname", php3_oci8_columnname, NULL},
! {"ocicolumnsize", php3_oci8_columnsize, NULL},
! {"ocicolumntype", php3_oci8_columntype, NULL},
! {NULL, NULL, NULL}
};
php3_module_entry oci8_module_entry = {
***************
*** 189,200 ****
OCI8_GLOBAL(php3_oci8_module).num_persistent = 0;
OCI8_GLOBAL(php3_oci8_module).le_conn =
! register_list_destructors(php3i_oci_close_conn, NULL);
! OCI8_GLOBAL(php3_oci8_module).le_pconn =
! register_list_destructors(php3i_oci_close_pconn, NULL);
/*
OCI8_GLOBAL(php3_oci8_module).le_conn =
! register_list_destructors(php3i_oci_close_conn, NULL);
*/
/*
--- 199,216 ----
OCI8_GLOBAL(php3_oci8_module).num_persistent = 0;
OCI8_GLOBAL(php3_oci8_module).le_conn =
! register_list_destructors(php3i_oci8_close_conn, NULL);
!
! OCI8_GLOBAL(php3_oci8_module).le_stmt =
! register_list_destructors(php3i_oci8_free_stmt, NULL);
!
! /* OCI8_GLOBAL(php3_oci8_module).le_pconn =
! register_list_destructors(php3i_oci8_close_pconn, NULL);
! */
!
/*
OCI8_GLOBAL(php3_oci8_module).le_conn =
! register_list_destructors(php3i_oci8_close_conn, NULL);
*/
/*
***************
*** 256,262 ****
/* {{{ extension-internal functions */
#if 0
! static int php3i_oci_cleanup_cursors(list_entry *le)
{
OCI8_TLS_VARS;
--- 272,278 ----
/* {{{ extension-internal functions */
#if 0
! static int php3i_oci8_cleanup_cursors(list_entry *le)
{
OCI8_TLS_VARS;
***************
*** 273,288 ****
}
#endif
! static void php3i_oci_close_conn(oci8_connection *connection)
{
OCI8_TLS_VARS;
connection->open = 0;
- #if 0
- _php3_hash_apply(OCI8_GLOBAL(php3_oci8_module).list,
- (int (*)(void *))php3i_oci_cleanup_cursors);
- #endif
php3i_oci8_error(connection->pError, "OCILogoff",
OCILogoff(connection->pServiceContext,
connection->pError));
--- 289,313 ----
}
#endif
+
+ static void
+ php3i_oci8_free_stmt(oci8_statement *statement)
+ {
+ OCI8_TLS_VARS;
+
+ OCI8_DEBUG("Freeing statement handle for \"%s\".", statement->last_query);
+ OCIHandleFree(statement->pStmt, OCI_HTYPE_STMT);
+ OCIHandleFree(statement->pError, OCI_HTYPE_ERROR);
+ efree(statement->last_query);
+ efree(statement);
+ }
! static void
! php3i_oci8_close_conn(oci8_connection *connection)
{
OCI8_TLS_VARS;
connection->open = 0;
php3i_oci8_error(connection->pError, "OCILogoff",
OCILogoff(connection->pServiceContext,
connection->pError));
***************
*** 291,305 ****
}
! static void php3i_oci_close_pconn(oci8_connection *connection)
{
OCI8_TLS_VARS;
connection->open = 0;
! #if 0
! _php3_hash_apply(OCI8_GLOBAL(php3_oci8_module).plist,
! (int (*)(void *))php3i_oci_cleanup_cursors);
! #endif
php3i_oci8_error(connection->pError, "OCILogoff",
OCILogoff(connection->pServiceContext,
connection->pError));
--- 316,328 ----
}
! /*
! static void php3i_oci8_close_pconn(oci8_connection *connection)
{
OCI8_TLS_VARS;
connection->open = 0;
! OCI8_DEBUG("Logging off with pconn %08x.", connection);
php3i_oci8_error(connection->pError, "OCILogoff",
OCILogoff(connection->pServiceContext,
connection->pError));
***************
*** 307,312 ****
--- 330,336 ----
OCI8_GLOBAL(php3_oci8_module).num_persistent--;
free(connection);
}
+ */
static ub4
***************
*** 349,355 ****
/* test if a connection is still alive and return 1 if it is */
! static int php3i_oci_ping(oci8_connection *conn)
{
/* XXX FIXME not yet implemented */
return 1;
--- 373,379 ----
/* test if a connection is still alive and return 1 if it is */
! static int php3i_oci8_ping(oci8_connection *conn)
{
/* XXX FIXME not yet implemented */
return 1;
***************
*** 380,386 ****
/* {{{ OCIDebug() */
! void php3_oci_debug(INTERNAL_FUNCTION_PARAMETERS)
{
pval *arg;
--- 404,410 ----
/* {{{ OCIDebug() */
! void php3_oci8_debug(INTERNAL_FUNCTION_PARAMETERS)
{
pval *arg;
***************
*** 396,424 ****
/* {{{ OCILogon() */
/* int OCILogon(string, string[, string])
- */
- void php3_oci_logon(INTERNAL_FUNCTION_PARAMETERS)
- {
- php3_oci_do_logon(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
- }
-
- /* int OCIPLogon(string, string[, string])
*/
! void php3_oci_plogon(INTERNAL_FUNCTION_PARAMETERS)
{
- php3_oci_do_logon(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
- }
-
- void php3_oci_do_logon(INTERNAL_FUNCTION_PARAMETERS, int persistent)
- {
text *username, *password, *dbname;
pval *userParam, *passParam, *dbParam;
ub4 username_len, password_len, dbname_len;
oci8_connection *connection;
- list_entry *index_ptr;
sword error;
- char *hashed_details;
- int hashed_len, len, id;
OCI8_TLS_VARS;
if (getParameters(ht, 3, &userParam, &passParam, &dbParam) == SUCCESS) {
--- 420,433 ----
/* {{{ OCILogon() */
/* int OCILogon(string, string[, string])
*/
! void php3_oci8_logon(INTERNAL_FUNCTION_PARAMETERS)
{
text *username, *password, *dbname;
pval *userParam, *passParam, *dbParam;
ub4 username_len, password_len, dbname_len;
oci8_connection *connection;
sword error;
OCI8_TLS_VARS;
if (getParameters(ht, 3, &userParam, &passParam, &dbParam) == SUCCESS) {
***************
*** 442,451 ****
username_len = userParam->value.str.len;
password_len = passParam->value.str.len;
- if (!OCI8_GLOBAL(php3_oci8_module).allow_persistent) {
- persistent = 0;
- }
-
if (OCI8_GLOBAL(php3_oci8_module).max_links != -1 &&
OCI8_GLOBAL(php3_oci8_module).num_links >=
OCI8_GLOBAL(php3_oci8_module).max_links) {
--- 451,456 ----
***************
*** 454,604 ****
RETURN_FALSE;
}
! /* the user requested a persistent connection */
! if (persistent &&
! OCI8_GLOBAL(php3_oci8_module).max_persistent != -1 &&
! OCI8_GLOBAL(php3_oci8_module).num_persistent >=
! OCI8_GLOBAL(php3_oci8_module).max_persistent) {
! php3_error(E_WARNING,"OCI8: Too many open persistent links (%d)",
! OCI8_GLOBAL(php3_oci8_module).num_persistent);
! RETURN_FALSE;
! }
!
! len = username_len + password_len + 9;
! if (dbname) {
! len += dbname_len + 1;
! }
! if ((hashed_details = emalloc(len)) == NULL) {
! RETURN_OUT_OF_MEMORY;
! }
! if (dbname) {
! hashed_len = _php3_sprintf(hashed_details, "oci8(%s,%s,%s)",
! username, password, dbname);
! } else {
! hashed_len = _php3_sprintf(hashed_details, "oci8(%s,%s)",
! username, password);
! }
! /* try to find if we already have this link in our persistent list,
! * no matter if it is to be persistent or not
! */
!
! if (_php3_hash_find(plist, hashed_details, hashed_len + 1,
! (void **) &index_ptr) == FAILURE) {
! /* the link is not in the persistent list */
! list_entry new_index_ptr;
!
! OCI8_DEBUG("Connection \"%s\" not found in plist.", hashed_details);
!
! if (persistent) {
! connection = (oci8_connection *)malloc(sizeof(oci8_connection));
! } else {
! connection = (oci8_connection *)emalloc(sizeof(oci8_connection));
! }
! if (connection == NULL) {
! efree(hashed_details);
! RETURN_OUT_OF_MEMORY;
! }
!
! /* Set up the Oracle environment. We can specify our own
! * malloc/realloc/free functions to OCIInitialize, but
! * we don't do that yet.
! */
! OCIInitialize(OCI_DEFAULT, NULL, NULL, NULL, NULL);
! OCIEnvInit(&connection->pEnv, OCI_DEFAULT, 0, NULL);
! OCIHandleAlloc(connection->pEnv, (dvoid **)&connection->pError,
! OCI_HTYPE_ERROR, 0, NULL);
! OCIHandleAlloc(connection->pEnv,
! (dvoid **)&connection->pServiceContext,
! OCI_HTYPE_SVCCTX, 0, NULL);
! error = OCILogon(connection->pEnv, connection->pError,
! &connection->pServiceContext,
! username, username_len,
! password, password_len,
! dbname, dbname_len);
! if (error) {
! efree(hashed_details);
! persistent ? free(connection) : efree(connection);
! OCI8_FAIL(connection, "OCILogon", error);
! }
! connection->open = 1;
! OCI8_DEBUG("\"%s\" created and connected.",
! hashed_details);
! if (persistent) {
! new_index_ptr.ptr = (void *) return_value->value.lval;
! new_index_ptr.type = le_index_ptr;
!
! if (_php3_hash_update(plist, hashed_details, hashed_len + 1,
! (void *) &new_index_ptr,
! sizeof(list_entry),NULL) == FAILURE) {
! php3i_oci8_error(connection->pError, "OCILogoff",
! OCILogoff(connection->pServiceContext,
! connection->pError));
! free(connection);
! efree(hashed_details);
! php3_error(E_WARNING, "OCILogon: can't update plist");
! RETURN_FALSE;
! }
! OCI8_GLOBAL(php3_oci8_module).num_persistent++;
!
! /* add the connection to the non-persistent list */
! return_value->value.lval =
! php3_list_insert(connection,
! OCI8_GLOBAL(php3_oci8_module).le_pconn);
! OCI8_DEBUG("\"%s\" inserted as le_pconn in list with id %d.",
! hashed_details, return_value->value.lval);
! } else {
! /* non persistent, simply add to list */
! return_value->value.lval =
! php3_list_insert(connection,
! OCI8_GLOBAL(php3_oci8_module).le_conn);
! OCI8_DEBUG("\"%s\" inserted as le_conn in list with id %s.",
! return_value->value.lval);
}
!
! OCI8_GLOBAL(php3_oci8_module).num_links++;
!
! } else {
! /* the link is already in the persistent list */
! int type;
!
! if (index_ptr->type != le_index_ptr) {
! efree(hashed_details);
! php3_error(E_WARNING, "Oops, something went completly wrong");
RETURN_FALSE;
}
- id = (int) index_ptr->ptr;
- connection = (oci8_connection *)php3_plist_find(id, &type);
! if (connection && (type == OCI8_GLOBAL(php3_oci8_module).le_conn ||
! type == OCI8_GLOBAL(php3_oci8_module).le_pconn)) {
! if (!php3i_oci_ping(connection)) {
! /* if the connection was lost, try reconnecting */
! error = OCILogon(connection->pEnv, connection->pError,
! &connection->pServiceContext,
! username, username_len,
! password, password_len,
! dbname, dbname_len);
! if (error) {
! /* delete list entry for this connection */
! php3_list_delete(id);
! /* delete hashed plist entry for this dead connection */
! _php3_hash_del(plist, hashed_details, hashed_len);
! efree(hashed_details);
! OCI8_FAIL(connection, "OCILogon", error);
! }
! }
! return_value->value.lval = id;
! }
}
! efree(hashed_details);
! return_value->type = IS_LONG;
}
! /* }}} */
#endif
--- 459,757 ----
RETURN_FALSE;
}
! connection = (oci8_connection *)emalloc(sizeof(oci8_connection));
! if (connection == NULL) {
! RETURN_OUT_OF_MEMORY;
! }
! /* Set up the Oracle environment. We can specify our own
! * malloc/realloc/free functions to OCIInitialize, but
! * we don't do that yet.
! */
! OCIInitialize(OCI_DEFAULT, NULL, NULL, NULL, NULL);
! OCIEnvInit(&connection->pEnv, OCI_DEFAULT, 0, NULL);
! OCIHandleAlloc(connection->pEnv, (dvoid **)&connection->pError,
! OCI_HTYPE_ERROR, 0, NULL);
! OCIHandleAlloc(connection->pEnv,
! (dvoid **)&connection->pServiceContext,
! OCI_HTYPE_SVCCTX, 0, NULL);
!
! error = OCILogon(connection->pEnv, connection->pError,
! &connection->pServiceContext,
! username, username_len,
! password, password_len,
! dbname, dbname_len);
! if (error) {
! php3i_oci8_error(connection->pError, "OCILogon", error);
! RETURN_FALSE;
! }
! connection->open = 1;
! /* non persistent, simply add to list */
! RETVAL_LONG(php3_list_insert(connection, OCI8_GLOBAL(php3_oci8_module).le_conn));
! OCI8_GLOBAL(php3_oci8_module).num_links++;
! }
!
! /* }}} */
! /* {{{ OCILogoff() */
!
! void php3_oci8_logoff(INTERNAL_FUNCTION_PARAMETERS)
! {
! oci8_connection *connection;
! pval *arg;
! int index, index_t;
! OCI8_TLS_VARS;
!
! if (getParameters(ht, 1, &arg) == FAILURE) {
! WRONG_PARAM_COUNT;
! }
! convert_to_long(arg);
! index = arg->value.lval;
! connection = (oci8_connection *)php3_list_find(index, &index_t);
! if (!connection || !OCI8_CONN_TYPE(index_t)) {
! return;
! }
! if (php3_list_delete(index) == SUCCESS) {
! RETVAL_TRUE;
! } else {
! OCI8_DEBUG("OCILogoff: php3_list_delete failed.");
! }
! }
!
! /* }}} */
!
!
! /* int OCIParse(int conn, string query) */
! void php3_oci8_parse(INTERNAL_FUNCTION_PARAMETERS)
! {
! pval *arg1, *arg2;
! oci8_connection *connection;
! oci8_statement *statement;
! char *query;
! int query_len, conn, type;
! sword error;
!
! if (getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
! WRONG_PARAM_COUNT;
! }
!
! convert_to_long(arg1);
! convert_to_string(arg2);
!
! conn = arg1->value.lval;
! connection = (oci8_connection *)php3_list_find(conn, &type);
! if (!connection || !OCI8_CONN_TYPE(type)) {
! php3_error(E_WARNING, "Invalid connection handle (%d).", conn);
! RETURN_FALSE;
! }
!
! query = arg2->value.str.val;
! query_len = arg2->value.str.len;
!
! statement = emalloc(sizeof(oci8_statement));
! OCIHandleAlloc(connection->pEnv, (dvoid **)&statement->pStmt,
! OCI_HTYPE_STMT, 0, NULL);
! OCIHandleAlloc(connection->pEnv, (dvoid **)&statement->pError,
! OCI_HTYPE_ERROR, 0, NULL);
! error = php3i_oci8_error(statement->pError, "OCIStmtPrepare",
! OCIStmtPrepare(statement->pStmt,
! connection->pError,
! query, query_len,
! OCI_NTV_SYNTAX, OCI_DEFAULT));
! if (error) {
! RETURN_FALSE;
! }
!
! statement->last_query = estrndup(query, query_len);
! statement->conn = connection;
! RETVAL_LONG(php3_list_insert(statement,
! OCI8_GLOBAL(php3_oci8_module).le_stmt));
! }
!
!
! void php3_oci8_execute(INTERNAL_FUNCTION_PARAMETERS)
! {
! pval *arg;
! oci8_statement *statement;
! oci8_out_column *outcol;
! OCIParam *param;
! int stmt, type, counter;
! sword error;
!
! if (getParameters(ht, 1, &arg) == FAILURE) {
! WRONG_PARAM_COUNT;
! }
! convert_to_long(arg);
! stmt = arg->value.lval;
!
! statement = (oci8_statement *)php3_list_find(stmt, &type);
! if (!statement || !OCI8_STMT_TYPE(type)) {
! php3_error(E_WARNING, "Invalid statement handle (%d).", stmt);
! RETURN_FALSE;
! }
!
! error = OCIStmtExecute(statement->conn->pServiceContext,
! statement->pStmt, statement->pError,
! 0, 0, NULL, NULL, OCI_DEFAULT);
! if (error) {
! php3i_oci8_error(statement->pError, statement->last_query, error);
! RETURN_FALSE;
! }
!
! statement->columns = emalloc(sizeof(HashTable));
! if (!statement->columns ||
! _php3_hash_init(statement->columns, 13, NULL, NULL, 0) == FAILURE) {
! RETURN_OUT_OF_MEMORY;
! }
!
! OCIHandleAlloc(statement->conn->pEnv, (dvoid **)¶m,
! OCI_DTYPE_PARAM, 0, NULL);
! counter = 1;
! error = OCIParamGet(statement->pStmt, OCI_HTYPE_STMT, statement->pError,
! (dvoid *)¶m, counter);
! php3i_oci8_error(statement->pError, "OCIParamGet", error);
! while (error == OCI_SUCCESS) {
! outcol = emalloc(sizeof(oci8_out_column));
! if (_php3_hash_index_update(statement->columns, counter, outcol,
! sizeof(oci8_out_column), NULL) == FAILURE) {
! efree(outcol->data);
! efree(outcol);
! efree(statement->columns);
! RETURN_OUT_OF_MEMORY;
}
! efree(outcol);
! _php3_hash_index_find(statement->columns, counter, (void **)&outcol);
!
! /* get data type */
! php3i_oci8_error(statement->pError, "OCIAttrGet(Parameter,DataType)",
! OCIAttrGet((dvoid *)param, OCI_DTYPE_PARAM,
! (dvoid *)&outcol->type, (ub4 *)0,
! OCI_ATTR_DATA_TYPE, statement->pError));
! /* get data size */
! php3i_oci8_error(statement->pError, "OCIAttrGet(Parameter,DataSize)",
! OCIAttrGet((dvoid *)param, OCI_DTYPE_PARAM,
! (dvoid *)&outcol->max_size, (dvoid *)0,
! OCI_ATTR_DATA_SIZE, statement->pError));
! /* get column name */
! php3i_oci8_error(statement->pError, "OCIAttrGet(Parameter,ColumnName)",
! OCIAttrGet((dvoid *)param, OCI_DTYPE_PARAM,
! (dvoid **)&outcol->name,
! (ub4 *)&outcol->name_len,
! (ub4)OCI_ATTR_NAME, statement->pError));
!
! outcol->data = (text *)emalloc(outcol->max_size + 1);
!
! if (php3i_oci8_error(statement->pError, "OCIDefineByPos",
! OCIDefineByPos(statement->pStmt,
! (OCIDefine **)&outcol->pDefine,
! statement->pError, counter,
! (dvoid *)outcol->data,
! outcol->max_size, SQLT_STR,
! (dvoid *)0, (ub2 *)0, (ub2 *)0,
! OCI_DEFAULT))) {
! efree(outcol->data);
! efree(outcol);
! efree(statement->columns);
RETURN_FALSE;
}
! counter++;
! error = OCIParamGet(statement->pStmt, OCI_HTYPE_STMT,
! statement->pError, (dvoid *)¶m, counter);
}
!
!
! RETURN_TRUE;
}
!
! void php3_oci8_columnname(INTERNAL_FUNCTION_PARAMETERS)
! {
! pval *arg1, *arg2;
! oci8_statement *statement;
! oci8_out_column *outcol;
! int stmt, type, col;
!
! if (getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
! WRONG_PARAM_COUNT;
! }
! convert_to_long(arg1);
! convert_to_long(arg2);
! stmt = arg1->value.lval;
! col = arg2->value.lval;
! statement = (oci8_statement *)php3_list_find(stmt, &type);
! if (!statement || !OCI8_STMT_TYPE(type)) {
! php3_error(E_WARNING, "Invalid statement handle (%d).", stmt);
! RETURN_FALSE;
! }
! if (_php3_hash_index_find(statement->columns, col, (void **)&outcol) ==
! FAILURE) {
! php3_error(E_WARNING, "No such column (%d).", col);
! RETURN_FALSE;
! }
!
! RETVAL_STRING(outcol->name, 1);
! }
!
!
! void php3_oci8_columnsize(INTERNAL_FUNCTION_PARAMETERS)
! {
! pval *arg1, *arg2;
! oci8_statement *statement;
! oci8_out_column *outcol;
! int stmt, type, col;
!
! if (getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
! WRONG_PARAM_COUNT;
! }
! convert_to_long(arg1);
! convert_to_long(arg2);
! stmt = arg1->value.lval;
! col = arg2->value.lval;
! statement = (oci8_statement *)php3_list_find(stmt, &type);
! if (!statement || !OCI8_STMT_TYPE(type)) {
! php3_error(E_WARNING, "Invalid statement handle (%d).", stmt);
! RETURN_FALSE;
! }
! if (_php3_hash_index_find(statement->columns, col, (void **)&outcol) ==
! FAILURE) {
! php3_error(E_WARNING, "No such column (%d).", col);
! RETURN_FALSE;
! }
!
! RETVAL_LONG(outcol->max_size);
! }
!
!
! void php3_oci8_columntype(INTERNAL_FUNCTION_PARAMETERS)
! {
! pval *arg1, *arg2;
! oci8_statement *statement;
! oci8_out_column *outcol;
! int stmt, type, col;
!
! if (getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
! WRONG_PARAM_COUNT;
! }
! convert_to_long(arg1);
! convert_to_long(arg2);
! stmt = arg1->value.lval;
! col = arg2->value.lval;
! statement = (oci8_statement *)php3_list_find(stmt, &type);
! if (!statement || !OCI8_STMT_TYPE(type)) {
! php3_error(E_WARNING, "Invalid statement handle (%d).", stmt);
! RETURN_FALSE;
! }
! if (_php3_hash_index_find(statement->columns, col, (void **)&outcol) ==
! FAILURE) {
! php3_error(E_WARNING, "No such column (%d).", col);
! RETURN_FALSE;
! }
!
! RETVAL_LONG(outcol->type);
! }
#endif
Index: php3/functions/php3_oci8.h
diff -c php3/functions/php3_oci8.h:1.2 php3/functions/php3_oci8.h:1.3
*** php3/functions/php3_oci8.h:1.2 Wed Sep 9 08:38:09 1998
--- php3/functions/php3_oci8.h Wed Sep 9 14:33:21 1998
***************
*** 59,73 ****
OCIEnv *pEnv;
OCIError *pError;
OCISvcCtx *pServiceContext;
- /* OCIServer *pServer; */
int open;
} oci8_connection;
typedef struct {
! OCIStmt *pStatement;
} oci8_statement;
typedef struct {
char *default_username;
char *default_password;
char *default_dbname;
--- 59,87 ----
OCIEnv *pEnv;
OCIError *pError;
OCISvcCtx *pServiceContext;
int open;
} oci8_connection;
typedef struct {
! oci8_connection *conn;
! OCIError *pError;
! OCIStmt *pStmt;
! text *last_query;
! HashTable *columns;
! HashTable *binds;
} oci8_statement;
typedef struct {
+ OCIDefine *pDefine;
+ text *name;
+ ub4 name_len;
+ ub2 type;
+ ub2 size;
+ ub2 max_size;
+ text *data;
+ } oci8_out_column;
+
+ typedef struct {
char *default_username;
char *default_password;
char *default_dbname;
***************
*** 78,91 ****
long num_persistent;
long num_links;
int le_conn;
! int le_pconn;
! int le_cursor;
HashTable *list;
HashTable *plist;
} oci8_module;
extern php3_module_entry oci8_module_entry;
# define oci8_module_ptr &oci8_module_entry
# define RETURN_OUT_OF_MEMORY \
php3_error(E_WARNING, "Out of memory");\
--- 92,108 ----
long num_persistent;
long num_links;
int le_conn;
! /* int le_pconn;*/
! int le_stmt;
HashTable *list;
HashTable *plist;
} oci8_module;
extern php3_module_entry oci8_module_entry;
# define oci8_module_ptr &oci8_module_entry
+
+ # define OCI8_CONN_TYPE(x) ((x)==OCI8_GLOBAL(php3_oci8_module).le_conn)
+ # define OCI8_STMT_TYPE(x) ((x)==OCI8_GLOBAL(php3_oci8_module).le_stmt)
# define RETURN_OUT_OF_MEMORY \
php3_error(E_WARNING, "Out of memory");\
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net