CVS update: php3/functions
| From: | ssb | Date: | Thu, 01 Oct 1998 18:21:55 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-1585@lists.php.net to get a copy of this message | ||
Date: Thursday October 1, 1998 @ 14:21
Author: ssb
Update of /repository/php3/functions
In directory asf:/u2/tmp/cvs-serv5478
Modified Files:
oci8.c
Log Message:
added OCIFreeStatement(), removed some test functions, sorted some stuff
Index: php3/functions/oci8.c
diff -c php3/functions/oci8.c:1.17 php3/functions/oci8.c:1.18
*** php3/functions/oci8.c:1.17 Mon Sep 28 11:39:41 1998
--- php3/functions/oci8.c Thu Oct 1 14:21:54 1998
***************
*** 30,36 ****
+----------------------------------------------------------------------+
*/
! /* $Id: oci8.c,v 1.17 1998/09/28 15:39:41 ssb Exp $ */
#include "php.h"
#include "internal_functions.h"
--- 30,36 ----
+----------------------------------------------------------------------+
*/
! /* $Id: oci8.c,v 1.18 1998/10/01 18:21:54 ssb Exp $ */
#include "php.h"
#include "internal_functions.h"
***************
*** 162,169 ****
void php3_oci8_serverversion(INTERNAL_FUNCTION_PARAMETERS);
void php3_oci8_bindbyname(INTERNAL_FUNCTION_PARAMETERS);
void php3_oci8_statementtype(INTERNAL_FUNCTION_PARAMETERS);
- void php3_oci8_test(INTERNAL_FUNCTION_PARAMETERS);
- void php3_oci8_test2(INTERNAL_FUNCTION_PARAMETERS);
/* }}} */
/* {{{ extension definition structures */
--- 162,167 ----
***************
*** 188,195 ****
{"ociserverversion", php3_oci8_serverversion, NULL},
{"ocibindbyname", php3_oci8_bindbyname, refs_aaf},
{"ocistatementtype", php3_oci8_statementtype, NULL},
- {"ocitest", php3_oci8_test, first_arg_force_ref},
- {"ocitest2", php3_oci8_test2, NULL},
{NULL, NULL, NULL}
};
--- 186,191 ----
***************
*** 350,355 ****
--- 346,352 ----
#endif
/* }}} */
+ /* {{{ oci8_free_column() */
static int
oci8_free_column(oci8_out_column *column)
***************
*** 363,368 ****
--- 360,366 ----
return 0;
}
+ /* }}} */
/* {{{ oci8_free_stmt() */
static void
***************
*** 831,855 ****
oci8_bind *phpbind;
pval *val;
! oci8_debug("oci8_bind_out_callback: iter=%d index=%d alen=%d", iter, index,
*(*alenpp));
phpbind = (oci8_bind *)ctxp;
val = phpbind->value;
if (val == NULL) {
return OCI_ERROR;
}
if (phpbind->is_opaque) {
oci8_debug("OUT binding of opaque types not yet implemented");
return OCI_ERROR;
} else {
! /* non-opaque values always get converted to strings */
! convert_to_string(val);
phpbind->buf = (dvoid *)val->value.str.val;
phpbind->size = (ub4)val->value.str.len;
*alenpp = (dvoid *)&phpbind->buf;
*bufpp = (dvoid *)&phpbind->size;
*piecep = OCI_ONE_PIECE;
*indpp = (dvoid *)&phpbind->indicator;
}
return OCI_CONTINUE;
--- 829,869 ----
oci8_bind *phpbind;
pval *val;
! oci8_debug("oci8_bind_out_callback: iter=%d index=%d alen=%d piece=%d",
! iter, index, **alenpp, *piecep);
phpbind = (oci8_bind *)ctxp;
+ if (!phpbind) {
+ oci8_debug("oci8_bind_out_callback: phpbind = NULL");
+ return OCI_ERROR;
+ }
val = phpbind->value;
if (val == NULL) {
+ oci8_debug("oci8_bind_out_callback: phpbind->value = NULL");
return OCI_ERROR;
}
if (phpbind->is_opaque) {
oci8_debug("OUT binding of opaque types not yet implemented");
return OCI_ERROR;
} else {
! /* XXX risky, if the variable has been freed, nasty things
! * could happen here.
! */
! if (val->type == IS_STRING && val->value.str.val) {
! efree(val->value.str.val);
! }
! val->type = IS_STRING;
!
! phpbind->buf = val->value.str.val;
! phpbind->size = val->value.str.len + 1;
! #if 0
phpbind->buf = (dvoid *)val->value.str.val;
phpbind->size = (ub4)val->value.str.len;
*alenpp = (dvoid *)&phpbind->buf;
*bufpp = (dvoid *)&phpbind->size;
*piecep = OCI_ONE_PIECE;
*indpp = (dvoid *)&phpbind->indicator;
+ #endif
}
return OCI_CONTINUE;
***************
*** 860,1045 ****
/* }}} */
/************************* 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;
- }
- convert_to_long(arg);
- OCI8_GLOBAL(php3_oci8_module).debug_mode = arg->value.lval;
- }
!
! /* }}} */
! /* {{{ 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)
{
! 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) {
! convert_to_string(userParam);
! convert_to_string(passParam);
! convert_to_string(dbParam);
! username = userParam->value.str.val;
! password = passParam->value.str.val;
! dbname = dbParam->value.str.val;
! dbname_len = dbParam->value.str.len;
! } else if (getParameters(ht, 2, &userParam, &passParam) == SUCCESS) {
! convert_to_string(userParam);
! convert_to_string(passParam);
! username = userParam->value.str.val;
! password = passParam->value.str.val;
! dbname = (text *)NULL;
! dbname_len = 0;
! } else {
WRONG_PARAM_COUNT;
- }
- username_len = userParam->value.str.len;
- password_len = passParam->value.str.len;
-
- if (OCI8_GLOBAL(php3_oci8_module).max_links != -1 &&
- OCI8_GLOBAL(php3_oci8_module).num_links >=
- OCI8_GLOBAL(php3_oci8_module).max_links) {
- php3_error(E_WARNING, "OCILogon: Too many open links (%d)",
- OCI8_GLOBAL(php3_oci8_module).num_links);
- RETURN_FALSE;
- }
-
- connection = (oci8_connection *)ecalloc(1,sizeof(oci8_connection));
-
- if (connection == NULL) {
- RETURN_OUT_OF_MEMORY;
}
!
! /* Set up the Oracle environment. */
! #if 0
! OCIInitialize(OCI_DEFAULT, (dvoid *)connection, mymalloc, myrealloc, myfree);
! #else
! OCIInitialize(OCI_DEFAULT, NULL, NULL, NULL, NULL);
! #endif
! 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((OCIEnv *)connection->pEnv,
! (OCIError *)connection->pError,
! (OCISvcCtx **)&connection->pServiceContext,
! (CONST text *)username, (ub4)username_len,
! (CONST text *)password, (ub4)password_len,
! (CONST text *)dbname, (ub4)dbname_len);
! if (error) {
! 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++;
- }
-
- /* }}} */
- /* {{{ int OCILogoff(int conn) */
-
- /* Logs off and disconnects.
- */
- 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_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 *conn, *query;
- oci8_connection *connection;
- OCI8_TLS_VARS;
-
- if (getParameters(ht, 2, &conn, &query) == FAILURE) {
- WRONG_PARAM_COUNT;
}
!
! convert_to_long(conn);
! convert_to_string(query);
!
! connection = oci8_get_conn(conn->value.lval, "OCIParse", list, plist);
! if (connection == NULL) {
! RETURN_FALSE;
}
!
! RETVAL_LONG(oci8_parse(connection,
! query->value.str.val,
! query->value.str.len,
! list));
! }
!
! /* }}} */
! /* {{{ int OCIExecute(int stmt) */
!
! void php3_oci8_execute(INTERNAL_FUNCTION_PARAMETERS)
! {
! pval *stmt;
! oci8_statement *statement;
! OCI8_TLS_VARS;
!
! if (getParameters(ht, 1, &stmt) == FAILURE) {
! WRONG_PARAM_COUNT;
}
! convert_to_long(stmt);
! statement = oci8_get_stmt(stmt->value.lval, "OCIExecute", list);
! if (statement == NULL) {
RETURN_FALSE;
- }
-
- if (oci8_execute(statement, "OCIExecute")) {
- RETVAL_TRUE;
- } else {
- RETVAL_FALSE;
}
}
/* }}} */
--- 874,945 ----
/* }}} */
/************************* EXTENSION FUNCTIONS *************************/
! /* {{{ int OCIBindByName(int stmt, string name, mixed &var) */
! void php3_oci8_bindbyname(INTERNAL_FUNCTION_PARAMETERS)
{
! pval *stmt, *name, *var;
! oci8_statement *statement;
! oci8_bind *bind, *tmp_bind;
! sword error;
! if (getParameters(ht, 3, &stmt, &name, &var) == FAILURE) {
WRONG_PARAM_COUNT;
}
! convert_to_long(stmt);
! convert_to_string(name);
! convert_to_string(var);
! statement = oci8_get_stmt(stmt->value.lval, "OCIBindByName", list);
! if (statement == NULL) {
RETURN_FALSE;
}
! bind = ecalloc(1,sizeof(oci8_bind));
! if (!bind) {
! /* out of memory */
RETURN_FALSE;
}
! if (statement->binds == NULL) {
! statement->binds = emalloc(sizeof(HashTable));
! if (statement->binds == NULL ||
! _php3_hash_init(statement->binds, 13, NULL, NULL, 0) == FAILURE) {
! /* out of memory */
! RETURN_FALSE;
! }
}
! if (_php3_hash_next_index_insert(statement->binds, bind,
! sizeof(oci8_bind),
! (void **)&tmp_bind) == SUCCESS) {
! efree(bind);
! bind = tmp_bind;
}
! bind->value = var;
! error = OCIBindByName(statement->pStmt, /* statement handle */
! (OCIBind **)&bind->pBind, /* bind hdl (will alloc) */
! statement->pError, /* error handle */
! name->value.str.val, /* placeholder name */
! name->value.str.len, /* placeholder length */
! (dvoid *)0, /* in/out data */
! OCI8_GLOBAL(php3_oci8_module).max_bind_data_size,
! (ub2)SQLT_STR, /* in/out data type */
! (dvoid *)0, /* indicator (ignored) */
! (ub2 *)0, /* size array (ignored) */
! (ub2 *)0, /* return code (ignored) */
! (ub4)0, /* maxarr_len (PL/SQL only?) */
! (ub4 *)0, /* actual array size (PL/SQL only?) */
! OCI_DATA_AT_EXEC /* mode */);
! if (error != OCI_SUCCESS) {
! oci8_error(statement->pError, "OCIBindByName", error);
RETURN_FALSE;
}
+ error = OCIBindDynamic(bind->pBind,
+ statement->pError,
+ (dvoid *)bind,
+ oci8_bind_in_callback,
+ (dvoid *)bind,
+ oci8_bind_out_callback
+ );
+ RETVAL_TRUE;
}
/* }}} */
***************
*** 1184,1294 ****
}
/* }}} */
! /* {{{ int OCINumCols(int stmt) */
! void php3_oci8_numcols(INTERNAL_FUNCTION_PARAMETERS)
{
! pval *stmt;
! oci8_statement *statement;
OCI8_TLS_VARS;
! if (getParameters(ht, 1, &stmt) == FAILURE) {
WRONG_PARAM_COUNT;
- }
- convert_to_long(stmt);
- statement = oci8_get_stmt(stmt->value.lval, "OCINumCols", list);
- if (statement == NULL) {
- RETURN_FALSE;
}
! RETVAL_LONG(statement->ncolumns);
}
/* }}} */
! /* {{{ int OCIFetch(int stmt) */
! void php3_oci8_fetch(INTERNAL_FUNCTION_PARAMETERS)
{
pval *stmt;
oci8_statement *statement;
- ub4 nrows = 1; /* only one row at a time is supported for now */
OCI8_TLS_VARS;
if (getParameters(ht, 1, &stmt) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long(stmt);
!
! statement = oci8_get_stmt(stmt->value.lval, "OCIFetch", list);
if (statement == NULL) {
RETURN_FALSE;
}
! if (oci8_fetch(statement, nrows, "OCIFetch")) {
! RETVAL_TRUE;
} else {
RETVAL_FALSE;
}
}
/* }}} */
! /* {{{ string OCIResult(int stmt, mixed column) */
! void php3_oci8_result(INTERNAL_FUNCTION_PARAMETERS)
{
! pval *stmt, *col, *ret;
oci8_statement *statement;
! oci8_out_column *outcol;
OCI8_TLS_VARS;
! if (getParameters(ht, 2, &stmt, &col) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long(stmt);
! convert_to_long(col);
! statement = oci8_get_stmt(stmt->value.lval, "OCIResult", list);
if (statement == NULL) {
RETURN_FALSE;
}
! outcol = oci8_get_col(statement, col->value.lval, "OCIResult");
! if (outcol == NULL) {
! RETURN_FALSE;
! }
! ret = oci8_make_pval(outcol, "OCIResult");
! if (ret == NULL) {
! RETVAL_FALSE;
} else {
! memcpy(return_value, ret, sizeof(pval));
! }
! }
!
! /* }}} */
! /* {{{ 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);
}
/* }}} */
--- 1084,1156 ----
}
/* }}} */
! /* {{{ 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;
}
! convert_to_long(arg);
! OCI8_GLOBAL(php3_oci8_module).debug_mode = arg->value.lval;
}
+
/* }}} */
! /* {{{ int OCIExecute(int stmt) */
! void php3_oci8_execute(INTERNAL_FUNCTION_PARAMETERS)
{
pval *stmt;
oci8_statement *statement;
OCI8_TLS_VARS;
if (getParameters(ht, 1, &stmt) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long(stmt);
! statement = oci8_get_stmt(stmt->value.lval, "OCIExecute", list);
if (statement == NULL) {
RETURN_FALSE;
}
!
! if (oci8_execute(statement, "OCIExecute")) {
! RETVAL_TRUE;
} else {
RETVAL_FALSE;
}
}
/* }}} */
! /* {{{ int OCIFetch(int stmt) */
! void php3_oci8_fetch(INTERNAL_FUNCTION_PARAMETERS)
{
! pval *stmt;
oci8_statement *statement;
! ub4 nrows = 1; /* only one row at a time is supported for now */
OCI8_TLS_VARS;
! if (getParameters(ht, 1, &stmt) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long(stmt);
!
! statement = oci8_get_stmt(stmt->value.lval, "OCIFetch", list);
if (statement == NULL) {
RETURN_FALSE;
}
! if (oci8_fetch(statement, nrows, "OCIFetch")) {
! RETVAL_TRUE;
} else {
! RETVAL_FALSE;
}
}
/* }}} */
***************
*** 1335,1439 ****
}
/* }}} */
! /* {{{ int OCITest() */
! void php3_oci8_test(INTERNAL_FUNCTION_PARAMETERS)
{
! pval *var;
OCI8_TLS_VARS;
! if (getParameters(ht, 1, &var) == FAILURE) {
WRONG_PARAM_COUNT;
}
! RETURN_LONG((long)var);
}
/* }}} */
! /* {{{ string OCITest2(int ptr) */
! void php3_oci8_test2(INTERNAL_FUNCTION_PARAMETERS)
{
! pval *var;
! char buf[200];
OCI8_TLS_VARS;
! if (getParameters(ht, 1, &var) == FAILURE) {
WRONG_PARAM_COUNT;
}
- convert_to_long(var);
- var = (pval *)var->value.lval;
- snprintf(buf, sizeof(buf), "var=%08x var->value=%08x str=%s",
- var, var->value, var->value.str.val);
- buf[sizeof(buf)-1] = '\0';
- RETVAL_STRING(buf,1);
}
/* }}} */
! /* {{{ int OCIBindByName(int stmt, string name, mixed &var) */
! void php3_oci8_bindbyname(INTERNAL_FUNCTION_PARAMETERS)
{
! pval *stmt, *name, *var;
oci8_statement *statement;
! oci8_bind *bind, *tmp_bind;
! sword error;
! if (getParameters(ht, 3, &stmt, &name, &var) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long(stmt);
! convert_to_string(name);
! convert_to_string(var);
! statement = oci8_get_stmt(stmt->value.lval, "OCIBindByName", list);
if (statement == NULL) {
RETURN_FALSE;
}
! bind = ecalloc(1,sizeof(oci8_bind));
! if (!bind) {
! /* out of memory */
RETURN_FALSE;
}
! if (statement->binds == NULL) {
! statement->binds = emalloc(sizeof(HashTable));
! if (statement->binds == NULL ||
! _php3_hash_init(statement->binds, 13, NULL, NULL, 0) == FAILURE) {
! /* out of memory */
! RETURN_FALSE;
! }
}
! if (_php3_hash_next_index_insert(statement->binds, bind,
! sizeof(oci8_bind),
! (void **)&tmp_bind) == SUCCESS) {
! efree(bind);
! bind = tmp_bind;
}
! bind->value = var;
! error = OCIBindByName(statement->pStmt, /* statement handle */
! (OCIBind **)&bind->pBind, /* bind hdl (will alloc) */
! statement->pError, /* error handle */
! name->value.str.val, /* placeholder name */
! name->value.str.len, /* placeholder length */
! (dvoid *)0, /* in/out data */
! OCI8_GLOBAL(php3_oci8_module).max_bind_data_size,
! (ub2)SQLT_STR, /* in/out data type */
! (dvoid *)0, /* indicator (ignored) */
! (ub2 *)0, /* size array (ignored) */
! (ub2 *)0, /* return code (ignored) */
! (ub4)0, /* maxarr_len (PL/SQL only?) */
! (ub4 *)0, /* actual array size (PL/SQL only?) */
! OCI_DATA_AT_EXEC /* mode */);
if (error != OCI_SUCCESS) {
! oci8_error(statement->pError, "OCIBindByName", error);
RETURN_FALSE;
}
! error = OCIBindDynamic(bind->pBind,
! statement->pError,
! (dvoid *)bind,
! oci8_bind_in_callback,
! (dvoid *)bind,
! oci8_bind_out_callback
! );
! RETVAL_TRUE;
}
/* }}} */
--- 1197,1444 ----
}
/* }}} */
! /* {{{ int OCIFreeStatement(int stmt) */
! void php3_oci8_freestatement(INTERNAL_FUNCTION_PARAMETERS)
{
! pval *stmt;
! oci8_statement *statement;
OCI8_TLS_VARS;
! if (getParameters(ht, 1, &stmt) == FAILURE) {
WRONG_PARAM_COUNT;
+ }
+ convert_to_long(stmt);
+ statement = oci8_get_stmt(stmt->value.lval, "OCIFreeStatement", list);
+ if (statement == NULL) {
+ RETURN_FALSE;
}
!
! if (oci8_free_stmt(statement)) {
! RETVAL_TRUE;
! } else {
! RETVAL_FALSE;
! }
}
/* }}} */
! /* {{{ int OCILogoff(int conn) */
! /* Logs off and disconnects.
! */
! 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_FALSE;
+ }
+ if (php3_list_delete(index) == SUCCESS) {
+ RETVAL_TRUE;
+ } else {
+ oci8_debug("OCILogoff: php3_list_delete failed.");
+ RETVAL_FALSE;
}
}
/* }}} */
! /* {{{ 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)
{
! 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) {
! convert_to_string(userParam);
! convert_to_string(passParam);
! convert_to_string(dbParam);
! username = userParam->value.str.val;
! password = passParam->value.str.val;
! dbname = dbParam->value.str.val;
! dbname_len = dbParam->value.str.len;
! } else if (getParameters(ht, 2, &userParam, &passParam) == SUCCESS) {
! convert_to_string(userParam);
! convert_to_string(passParam);
! username = userParam->value.str.val;
! password = passParam->value.str.val;
! dbname = (text *)NULL;
! dbname_len = 0;
! } else {
! WRONG_PARAM_COUNT;
! }
! username_len = userParam->value.str.len;
! password_len = passParam->value.str.len;
!
! if (OCI8_GLOBAL(php3_oci8_module).max_links != -1 &&
! OCI8_GLOBAL(php3_oci8_module).num_links >=
! OCI8_GLOBAL(php3_oci8_module).max_links) {
! php3_error(E_WARNING, "OCILogon: Too many open links (%d)",
! OCI8_GLOBAL(php3_oci8_module).num_links);
! RETURN_FALSE;
! }
!
! connection = (oci8_connection *)ecalloc(1,sizeof(oci8_connection));
!
! if (connection == NULL) {
! RETURN_OUT_OF_MEMORY;
! }
!
! /* Set up the Oracle environment. */
! #if 0
! OCIInitialize(OCI_DEFAULT, (dvoid *)connection, mymalloc, myrealloc, myfree);
! #else
! OCIInitialize(OCI_DEFAULT, NULL, NULL, NULL, NULL);
! #endif
! 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((OCIEnv *)connection->pEnv,
! (OCIError *)connection->pError,
! (OCISvcCtx **)&connection->pServiceContext,
! (CONST text *)username, (ub4)username_len,
! (CONST text *)password, (ub4)password_len,
! (CONST text *)dbname, (ub4)dbname_len);
! if (error) {
! 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++;
! }
!
! /* }}} */
! /* {{{ int OCINumCols(int stmt) */
!
! void php3_oci8_numcols(INTERNAL_FUNCTION_PARAMETERS)
! {
! pval *stmt;
oci8_statement *statement;
! OCI8_TLS_VARS;
! if (getParameters(ht, 1, &stmt) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long(stmt);
! statement = oci8_get_stmt(stmt->value.lval, "OCINumCols", list);
if (statement == NULL) {
RETURN_FALSE;
}
! RETVAL_LONG(statement->ncolumns);
! }
!
! /* }}} */
! /* {{{ int OCIParse(int conn, string query) */
!
! void php3_oci8_parse(INTERNAL_FUNCTION_PARAMETERS)
! {
! pval *conn, *query;
! oci8_connection *connection;
! OCI8_TLS_VARS;
!
! if (getParameters(ht, 2, &conn, &query) == FAILURE) {
! WRONG_PARAM_COUNT;
! }
!
! convert_to_long(conn);
! convert_to_string(query);
!
! connection = oci8_get_conn(conn->value.lval, "OCIParse", list, plist);
! if (connection == NULL) {
RETURN_FALSE;
}
!
! RETVAL_LONG(oci8_parse(connection,
! query->value.str.val,
! query->value.str.len,
! list));
! }
!
! /* }}} */
! /* {{{ string OCIResult(int stmt, mixed column) */
!
! void php3_oci8_result(INTERNAL_FUNCTION_PARAMETERS)
! {
! pval *stmt, *col, *ret;
! oci8_statement *statement;
! oci8_out_column *outcol;
! OCI8_TLS_VARS;
!
! if (getParameters(ht, 2, &stmt, &col) == FAILURE) {
! WRONG_PARAM_COUNT;
}
! convert_to_long(stmt);
! convert_to_long(col);
! statement = oci8_get_stmt(stmt->value.lval, "OCIResult", list);
! if (statement == NULL) {
! RETURN_FALSE;
}
! outcol = oci8_get_col(statement, col->value.lval, "OCIResult");
! if (outcol == NULL) {
! RETURN_FALSE;
! }
! ret = oci8_make_pval(outcol, "OCIResult");
! if (ret == NULL) {
! RETVAL_FALSE;
! } else {
! memcpy(return_value, ret, sizeof(pval));
! }
! }
!
! /* }}} */
! /* {{{ 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);
}
/* }}} */
--
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