CVS update: php3/functions

From: Date: Thu, 10 Sep 1998 11:48:37 +0000
Subject: CVS update: php3/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-902@lists.php.net to get a copy of this message
Date: Thursday September 10, 1998 @ 7:48 Author: ssb Update of /repository/php3/functions In directory asf:/u2/tmp/cvs-serv23546 Modified Files: oci8.c Log Message: Added OCIFetch(), OCIResult() and OCIServerVersion(). Got a crasher bogey to hunt down still. Index: php3/functions/oci8.c diff -c php3/functions/oci8.c:1.5 php3/functions/oci8.c:1.6 *** php3/functions/oci8.c:1.5 Thu Sep 10 05:56:40 1998 --- php3/functions/oci8.c Thu Sep 10 07:48:37 1998 *************** *** 27,33 **** +----------------------------------------------------------------------+ */ ! /* $Id: oci8.c,v 1.5 1998/09/10 09:56:40 ssb Exp $ */ #include "php.h" #include "internal_functions.h" --- 27,33 ---- +----------------------------------------------------------------------+ */ ! /* $Id: oci8.c,v 1.6 1998/09/10 11:48:37 ssb Exp $ */ #include "php.h" #include "internal_functions.h" *************** *** 40,45 **** --- 40,61 ---- # include "snprintf.h" # include "head.h" + /* These {{{ and }}} lines are folding marks for Emacs, in case you + * wondered. + */ + + /* TODO list: + * + * - Error mode (print or shut up?) + * - Dynamic Binding + * - LOB writing, reading and manipulation + * - ability to refer to columns by name as well as number + * - OCIPasswordChange() + * - OCIServerVersion() + * - Prefetching control + * + */ + /* {{{ thread safety stuff */ # ifdef THREAD_SAFE *************** *** 107,124 **** int php3_rshutdown_oci8(void); 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); --- 123,140 ---- int php3_rshutdown_oci8(void); void php3_info_oci8(void); ! static ub4 oci8_error(OCIError *err_p, char *what, sword status); ! static int oci8_ping(oci8_connection *conn); ! static void oci8_debug(const char *format,...); ! static void oci8_close_conn(oci8_connection *connection); ! static void oci8_free_stmt(oci8_statement *statement); ! /*static void oci8_close_pconn(oci8_connection *connection);*/ /* }}} */ /* {{{ extension function prototypes */ ! void php3_oci8_internaldebug(INTERNAL_FUNCTION_PARAMETERS); void php3_oci8_logon(INTERNAL_FUNCTION_PARAMETERS); void php3_oci8_logoff(INTERNAL_FUNCTION_PARAMETERS); void php3_oci8_parse(INTERNAL_FUNCTION_PARAMETERS); *************** *** 127,148 **** void php3_oci8_columnsize(INTERNAL_FUNCTION_PARAMETERS); void php3_oci8_columntype(INTERNAL_FUNCTION_PARAMETERS); void php3_oci8_numcols(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}, ! {"ocinumcols", php3_oci8_numcols, NULL}, ! {NULL, NULL, NULL} }; php3_module_entry oci8_module_entry = { --- 143,170 ---- void php3_oci8_columnsize(INTERNAL_FUNCTION_PARAMETERS); void php3_oci8_columntype(INTERNAL_FUNCTION_PARAMETERS); void php3_oci8_numcols(INTERNAL_FUNCTION_PARAMETERS); + void php3_oci8_fetch(INTERNAL_FUNCTION_PARAMETERS); + void php3_oci8_result(INTERNAL_FUNCTION_PARAMETERS); + void php3_oci8_serverversion(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}, ! {"ociinternaldebug", php3_oci8_internaldebug, 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}, ! {"ocinumcols", php3_oci8_numcols, NULL}, ! {"ocifetch", php3_oci8_fetch, NULL}, ! {"ociresult", php3_oci8_result, NULL}, ! {"ociserverversion", php3_oci8_serverversion, NULL}, ! {NULL, NULL, NULL} }; php3_module_entry oci8_module_entry = { *************** *** 201,229 **** 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); ! */ ! ! /* ! REGISTER_LONG_CONSTANT("OCI_BIND_INOUT", 0, CONST_CS | CONST_PERSISTENT); ! REGISTER_LONG_CONSTANT("OCI_BIND_IN", 1, CONST_CS | CONST_PERSISTENT); ! REGISTER_LONG_CONSTANT("OCI_BIND_OUT", 2, CONST_CS | CONST_PERSISTENT); */ return SUCCESS; } int php3_rinit_oci8(INIT_FUNC_ARGS) { OCI8_TLS_VARS; --- 223,241 ---- OCI8_GLOBAL(php3_oci8_module).num_persistent = 0; OCI8_GLOBAL(php3_oci8_module).le_conn = ! register_list_destructors(oci8_close_conn, NULL); OCI8_GLOBAL(php3_oci8_module).le_stmt = ! register_list_destructors(oci8_free_stmt, NULL); /* OCI8_GLOBAL(php3_oci8_module).le_pconn = ! register_list_destructors(oci8_close_pconn, NULL); */ return SUCCESS; } + int php3_rinit_oci8(INIT_FUNC_ARGS) { OCI8_TLS_VARS; *************** *** 234,239 **** --- 246,252 ---- return SUCCESS; } + int php3_mshutdown_oci8() { #ifdef THREAD_SAFE *************** *** 257,267 **** --- 270,282 ---- return SUCCESS; } + int php3_rshutdown_oci8() { return SUCCESS; } + void php3_info_oci8() { php3_printf("Oracle version: %s<br>\n" *************** *** 273,316 **** /* }}} */ /* {{{ extension-internal functions */ - #if 0 - static int php3i_oci8_cleanup_cursors(list_entry *le) - { - OCI8_TLS_VARS; - - if (le->type == OCI8_GLOBAL(php3_oci8_module).le_cursor) { - oraCursor *curs = ((oraCursor *)le->ptr); - oraConnection *conn = curs->conn_ptr; - - if ((!(conn->open)) && (curs->open > 0)){ - oclose(&curs->cda); - curs->open = 0; - } - } - return 0; - } - #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)); OCI8_GLOBAL(php3_oci8_module).num_links--; --- 288,313 ---- /* }}} */ /* {{{ extension-internal functions */ static void ! 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 ! oci8_close_conn(oci8_connection *connection) { OCI8_TLS_VARS; connection->open = 0; ! oci8_error(connection->pError, "OCILogoff", OCILogoff(connection->pServiceContext, connection->pError)); OCI8_GLOBAL(php3_oci8_module).num_links--; *************** *** 318,342 **** } - /* - 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)); - OCI8_GLOBAL(php3_oci8_module).num_links--; - OCI8_GLOBAL(php3_oci8_module).num_persistent--; - free(connection); - } - */ - - static ub4 ! php3i_oci8_error(OCIError *err_p, char *what, sword status) { text errbuf[512]; ub4 errcode = 0; --- 315,322 ---- } static ub4 ! oci8_error(OCIError *err_p, char *what, sword status) { text errbuf[512]; ub4 errcode = 0; *************** *** 375,388 **** /* 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; } ! static void OCI8_DEBUG(const char *format,...) { OCI8_TLS_VARS; --- 355,368 ---- /* test if a connection is still alive and return 1 if it is */ ! static int oci8_ping(oci8_connection *conn) { /* XXX FIXME not yet implemented */ return 1; } ! static void oci8_debug(const char *format,...) { OCI8_TLS_VARS; *************** *** 404,414 **** /************************* EXTENSION FUNCTIONS *************************/ ! /* {{{ OCIDebug() */ ! void php3_oci8_debug(INTERNAL_FUNCTION_PARAMETERS) { pval *arg; if (getParameters(ht, 1, &arg) == FAILURE) { WRONG_PARAM_COUNT; --- 384,398 ---- /************************* EXTENSION FUNCTIONS *************************/ ! /* {{{ void OCIDebug(int onoff) */ ! /* Disables or enables the internal debug output. ! * By default it is disabled. ! */ ! void php3_oci8_internaldebug(INTERNAL_FUNCTION_PARAMETERS) { pval *arg; + OCI8_TLS_VARS; if (getParameters(ht, 1, &arg) == FAILURE) { WRONG_PARAM_COUNT; *************** *** 419,427 **** /* }}} */ ! /* {{{ OCILogon() */ ! /* int OCILogon(string, string[, string]) */ void php3_oci8_logon(INTERNAL_FUNCTION_PARAMETERS) { --- 403,413 ---- /* }}} */ ! /* {{{ int OCILogon(string user, string pass[, string db]) */ ! /* Connects to an Oracle 8 database and logs on. If the ! * optional third parameter is not specified, PHP uses the environment ! * variable ORACLE_SID to determine which database to connect to. */ void php3_oci8_logon(INTERNAL_FUNCTION_PARAMETERS) { *************** *** 485,491 **** password, password_len, dbname, dbname_len); if (error) { ! php3i_oci8_error(connection->pError, "OCILogon", error); RETURN_FALSE; } --- 471,477 ---- password, password_len, dbname, dbname_len); if (error) { ! oci8_error(connection->pError, "OCILogon", error); RETURN_FALSE; } *************** *** 497,504 **** } /* }}} */ ! /* {{{ OCILogoff() */ void php3_oci8_logoff(INTERNAL_FUNCTION_PARAMETERS) { oci8_connection *connection; --- 483,492 ---- } /* }}} */ ! /* {{{ int OCILogoff(int conn) */ + /* Logs off and disconnects. + */ void php3_oci8_logoff(INTERNAL_FUNCTION_PARAMETERS) { oci8_connection *connection; *************** *** 513,531 **** 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; --- 501,519 ---- index = arg->value.lval; connection = (oci8_connection *)php3_list_find(index, &index_t); if (!connection || !OCI8_CONN_TYPE(index_t)) { ! RETURN_FALSE; } if (php3_list_delete(index) == SUCCESS) { RETVAL_TRUE; } else { ! oci8_debug("OCILogoff: php3_list_delete failed."); ! RETVAL_FALSE; } } /* }}} */ + /* {{{ int OCIParse(int conn, string query) */ void php3_oci8_parse(INTERNAL_FUNCTION_PARAMETERS) { pval *arg1, *arg2; *************** *** 534,539 **** --- 522,528 ---- char *query; int query_len, conn, type; sword error; + OCI8_TLS_VARS; if (getParameters(ht, 2, &arg1, &arg2) == FAILURE) { WRONG_PARAM_COUNT; *************** *** 557,563 **** 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, --- 546,552 ---- OCI_HTYPE_STMT, 0, NULL); OCIHandleAlloc(connection->pEnv, (dvoid **)&statement->pError, OCI_HTYPE_ERROR, 0, NULL); ! error = oci8_error(statement->pError, "OCIStmtPrepare", OCIStmtPrepare(statement->pStmt, connection->pError, query, query_len, *************** *** 572,577 **** --- 561,568 ---- OCI8_GLOBAL(php3_oci8_module).le_stmt)); } + /* }}} */ + /* {{{ int OCIExecute(int stmt) */ void php3_oci8_execute(INTERNAL_FUNCTION_PARAMETERS) { *************** *** 582,587 **** --- 573,579 ---- int stmt, type, counter; sword error, def_error; ub2 define_type; + OCI8_TLS_VARS; if (getParameters(ht, 1, &arg) == FAILURE) { WRONG_PARAM_COUNT; *************** *** 599,605 **** statement->pStmt, statement->pError, 0, 0, NULL, NULL, OCI_DEFAULT); if (error) { ! php3i_oci8_error(statement->pError, statement->last_query, error); RETURN_FALSE; } --- 591,597 ---- statement->pStmt, statement->pError, 0, 0, NULL, NULL, OCI_DEFAULT); if (error) { ! oci8_error(statement->pError, statement->last_query, error); RETURN_FALSE; } *************** *** 614,620 **** counter = 1; error = OCIParamGet(statement->pStmt, OCI_HTYPE_STMT, statement->pError, (dvoid *)&param, counter); ! php3i_oci8_error(statement->pError, "OCIParamGet", error); while (error == OCI_SUCCESS) { outcol = ecalloc(1,sizeof(oci8_out_column)); if (_php3_hash_index_update(statement->columns, counter, outcol, --- 606,612 ---- counter = 1; error = OCIParamGet(statement->pStmt, OCI_HTYPE_STMT, statement->pError, (dvoid *)&param, counter); ! oci8_error(statement->pError, "OCIParamGet", error); while (error == OCI_SUCCESS) { outcol = ecalloc(1,sizeof(oci8_out_column)); if (_php3_hash_index_update(statement->columns, counter, outcol, *************** *** 624,667 **** efree(statement->columns); RETURN_OUT_OF_MEMORY; } else { ! OCI8_DEBUG("added info about column %d", counter); } 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)); /* "Scalar" data types are stored directly in strings, ! * while others, like large objects (LOBs) need to be * handled specially. */ switch (outcol->type) { case SQLT_BLOB: case SQLT_CLOB: ! case SQLT_BFILEE: ! case SQLT_CFILEE: define_type = outcol->type; break; default: define_type = SQLT_STR; break; } ! outcol->data = (text *)emalloc(outcol->max_size + 1); if (outcol->data == NULL) { efree(outcol); efree(statement->columns); --- 616,667 ---- efree(statement->columns); RETURN_OUT_OF_MEMORY; } else { ! oci8_debug("added info about column %d", counter); } efree(outcol); _php3_hash_index_find(statement->columns, counter, (void **)&outcol); /* get data type */ ! /* XXX can get OCI_ATTR_TYPE_NAME instead */ ! 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 */ ! oci8_error(statement->pError, "OCIAttrGet(Parameter,DataSize)", OCIAttrGet((dvoid *)param, OCI_DTYPE_PARAM, ! (dvoid *)&outcol->storage_size, (dvoid *)0, OCI_ATTR_DATA_SIZE, statement->pError)); /* get column name */ ! 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)); + /* Remember the size Oracle told us, we have to increase the + * storage size for some types. + */ + outcol->size = outcol->storage_size; + /* "Scalar" data types are stored directly in strings, ! * while others, like LOBs and RAW data need to be * handled specially. */ switch (outcol->type) { + case SQLT_BIN: + case SQLT_LBI: case SQLT_BLOB: case SQLT_CLOB: ! case SQLT_BFILE: define_type = outcol->type; break; default: define_type = SQLT_STR; + outcol->storage_size++; /* add one for string terminator */ break; } ! outcol->data = (text *)emalloc(outcol->storage_size); if (outcol->data == NULL) { efree(outcol); efree(statement->columns); *************** *** 672,683 **** (OCIDefine **)&outcol->pDefine, statement->pError, counter, (dvoid *)outcol->data, ! outcol->max_size, define_type, (dvoid *)0, (ub2 *)0, (ub2 *)0, OCI_DEFAULT); if (def_error) { ! php3i_oci8_error(statement->pError, "OCIDefineByPos", def_error); efree(outcol->data); efree(outcol); efree(statement->columns); --- 672,683 ---- (OCIDefine **)&outcol->pDefine, statement->pError, counter, (dvoid *)outcol->data, ! outcol->storage_size, define_type, (dvoid *)0, (ub2 *)0, (ub2 *)0, OCI_DEFAULT); if (def_error) { ! oci8_error(statement->pError, "OCIDefineByPos", def_error); efree(outcol->data); efree(outcol); efree(statement->columns); *************** *** 692,697 **** --- 692,699 ---- RETURN_TRUE; } + /* }}} */ + /* {{{ string OCIColumnName(int stmt, int col) */ void php3_oci8_columnname(INTERNAL_FUNCTION_PARAMETERS) { *************** *** 699,704 **** --- 701,707 ---- oci8_statement *statement; oci8_out_column *outcol; int stmt, type, col; + OCI8_TLS_VARS; if (getParameters(ht, 2, &arg1, &arg2) == FAILURE) { WRONG_PARAM_COUNT; *************** *** 718,726 **** RETURN_FALSE; } ! RETVAL_STRING(outcol->name, 1); } void php3_oci8_columnsize(INTERNAL_FUNCTION_PARAMETERS) { --- 721,731 ---- RETURN_FALSE; } ! RETVAL_STRINGL(outcol->name, outcol->name_len, 1); } + /* }}} */ + /* {{{ int OCIColumnSize(int stmt, int col) */ void php3_oci8_columnsize(INTERNAL_FUNCTION_PARAMETERS) { *************** *** 728,733 **** --- 733,739 ---- oci8_statement *statement; oci8_out_column *outcol; int stmt, type, col; + OCI8_TLS_VARS; if (getParameters(ht, 2, &arg1, &arg2) == FAILURE) { WRONG_PARAM_COUNT; *************** *** 747,755 **** RETURN_FALSE; } ! RETVAL_LONG(outcol->max_size); } void php3_oci8_columntype(INTERNAL_FUNCTION_PARAMETERS) { --- 753,763 ---- RETURN_FALSE; } ! RETVAL_LONG(outcol->size); } + /* }}} */ + /* {{{ mixed OCIColumnType(int stmt, int col) */ void php3_oci8_columntype(INTERNAL_FUNCTION_PARAMETERS) { *************** *** 757,762 **** --- 765,771 ---- oci8_statement *statement; oci8_out_column *outcol; int stmt, type, col; + OCI8_TLS_VARS; if (getParameters(ht, 2, &arg1, &arg2) == FAILURE) { WRONG_PARAM_COUNT; *************** *** 812,823 **** --- 821,835 ---- } } + /* }}} */ + /* {{{ int OCINumCols(int stmt) */ void php3_oci8_numcols(INTERNAL_FUNCTION_PARAMETERS) { pval *arg; oci8_statement *statement; int stmt, type; + OCI8_TLS_VARS; if (getParameters(ht, 1, &arg) == FAILURE) { WRONG_PARAM_COUNT; *************** *** 833,838 **** --- 845,956 ---- RETVAL_LONG(statement->ncolumns); } + /* }}} */ + /* {{{ int OCIFetch(int stmt) */ + + void php3_oci8_fetch(INTERNAL_FUNCTION_PARAMETERS) + { + pval *arg1; + oci8_statement *statement; + int stmt, type; + sword error; + ub4 nrows = 1; + OCI8_TLS_VARS; + + if (getParameters(ht, 1, &arg1) == FAILURE) { + WRONG_PARAM_COUNT; + } + convert_to_long(arg1); + stmt = arg1->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 = OCIStmtFetch(statement->pStmt, statement->pError, nrows, + OCI_FETCH_NEXT, OCI_DEFAULT); + oci8_debug("OCIStmtFetch returned %d", error); + if (error == OCI_NO_DATA) { + RETURN_FALSE; + } + if (error == OCI_SUCCESS_WITH_INFO) { + /* "Data was truncated or EOF was reached.", the documentation + * says. + */ + RETURN_FALSE; + } + if (error != OCI_SUCCESS) { + oci8_error(statement->pError, "OCIStmtFetch", error); + RETURN_FALSE; + } + RETVAL_TRUE; + } + + /* }}} */ + /* {{{ string OCIResult(int stmt, mixed column) */ + + void php3_oci8_result(INTERNAL_FUNCTION_PARAMETERS) + { + pval *arg1, *arg2; + oci8_statement *statement; + oci8_out_column *outcol; + int stmt, type, col; + OCI8_TLS_VARS; + + 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->data,0); + } + + /* }}} */ + /* {{{ string OCIServerVersion(int conn) */ + + void php3_oci8_serverversion(INTERNAL_FUNCTION_PARAMETERS) + { + oci8_connection *connection; + pval *arg; + int index, index_t; + sword error; + char version[256]; + 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_FALSE; + } + error = OCIServerVersion(connection->pServiceContext, + connection->pError, version, sizeof(version), + OCI_HTYPE_SVCCTX); + if (error != OCI_SUCCESS) { + oci8_error(connection->pError, "OCIServerVersion", error); + RETURN_FALSE; + } + RETVAL_STRING(version,1); + } + + /* }}} */ #endif -- 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

« previous php.dev (#902) next »