CVS update: php3/functions
| From: | thies | Date: | Mon, 08 Feb 1999 11:30:23 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-3975@lists.php.net to get a copy of this message | ||
Date: Monday February 8, 1999 @ 6:30
Author: thies
Update of /repository/php3/functions
In directory asf:/u/temp/cvs-serv18422
Modified Files:
oci8.c php3_oci8.h
Log Message:
bind to local/global variables (IN/OUT/BOTH)
initial LOB reading/writing support (no binding of lobs yet)
many fixes
-------------------------------
THIS IS STILL WORK IN PROGRESS!
- i'm pretty sure, that we have problems with binding on 64bit machines
oci8.c:994:
*alenpp = (ub4*) &phpbind->value->value.str.len; /* XXX we assume that php-pval len has
4 bytes */
- long rows should be read "smarter" (piecewise)
- no ref-cursor handling yet
Index: php3/functions/oci8.c
diff -c php3/functions/oci8.c:1.24 php3/functions/oci8.c:1.25
*** php3/functions/oci8.c:1.24 Wed Feb 3 13:21:01 1999
--- php3/functions/oci8.c Mon Feb 8 06:30:22 1999
***************
*** 24,36 ****
| contact core@php.net. |
+----------------------------------------------------------------------+
| Authors: Stig Sæther Bakken <ssb@guardian.no> |
| |
| Initial work sponsored by Thies Arntzen <thies@digicol.de> of |
| Digital Collections, http://www.digicol.de/
|
+----------------------------------------------------------------------+
*/
! /* $Id: oci8.c,v 1.24 1999/02/03 18:21:01 thies Exp $ */
#include "php.h"
#include "internal_functions.h"
--- 24,37 ----
| contact core@php.net. |
+----------------------------------------------------------------------+
| Authors: Stig Sæther Bakken <ssb@guardian.no> |
+ | Thies C. Arntzen <thies@digicol.de> |
| |
| Initial work sponsored by Thies Arntzen <thies@digicol.de> of |
| Digital Collections, http://www.digicol.de/
|
+----------------------------------------------------------------------+
*/
! /* $Id: oci8.c,v 1.25 1999/02/08 11:30:22 thies Exp $ */
#include "php.h"
#include "internal_functions.h"
***************
*** 55,60 ****
--- 56,62 ----
* - ability to refer to columns by name as well as number
* - OCIPasswordChange()
* - Prefetching control
+ * - support LONG > 64K
*
*/
***************
*** 163,168 ****
--- 165,171 ----
void php3_oci8_loadlob(INTERNAL_FUNCTION_PARAMETERS);
void php3_oci8_commit(INTERNAL_FUNCTION_PARAMETERS);
void php3_oci8_rollback(INTERNAL_FUNCTION_PARAMETERS);
+ void php3_oci8_newlob(INTERNAL_FUNCTION_PARAMETERS);
void php3_oci8_numcols(INTERNAL_FUNCTION_PARAMETERS);
void php3_oci8_parse(INTERNAL_FUNCTION_PARAMETERS);
void php3_oci8_result(INTERNAL_FUNCTION_PARAMETERS);
***************
*** 196,201 ****
--- 199,205 ----
{"ociloadlob", php3_oci8_loadlob, NULL},
{"ocicommit", php3_oci8_commit, NULL},
{"ocirollback", php3_oci8_rollback, NULL},
+ {"ocinewlob", php3_oci8_newlob, NULL},
{NULL, NULL, NULL}
};
***************
*** 263,273 ****
OCI8_GLOBAL(php3_oci8_module).le_stmt =
register_list_destructors(oci8_free_stmt, NULL);
- if (cfg_get_long("oci8.max_bind_data_size",
- &OCI8_GLOBAL(php3_oci8_module).max_bind_data_size) == FAILURE) {
- OCI8_GLOBAL(php3_oci8_module).max_bind_data_size = OCI8_MAX_DATA_SIZE;
- }
-
if (cfg_get_long("oci8.debug_mode",
&OCI8_GLOBAL(php3_oci8_module).debug_mode) == FAILURE) {
OCI8_GLOBAL(php3_oci8_module).debug_mode = 0;
--- 267,272 ----
***************
*** 280,289 ****
--- 279,312 ----
REGISTER_LONG_CONSTANT("OCI_COMMIT_ON_SUCCESS",OCI_COMMIT_ON_SUCCESS, CONST_CS |
CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OCI_EXACT_FETCH",OCI_EXACT_FETCH, CONST_CS | CONST_PERSISTENT);
+ /* types for OCIBindByName */
+ REGISTER_LONG_CONSTANT("SQLT_STR",SQLT_STR, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SQLT_BLOB",SQLT_BLOB, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("SQLT_CLOB",SQLT_CLOB, CONST_CS | CONST_PERSISTENT);
+
return SUCCESS;
}
+ #if test
+ static sb4 cbf_no_data(dvoid *ctxp, OCIBind *bindp, ub4 iter, ub4 index,
+ dvoid **bufpp, ub4 *alenpp, ub1 *piecep, dvoid **indpp)
+ {
+ /*
+ * This is a dummy input callback function that provides input data
+ * for the bind variables in the RETURNING clause.
+ */
+ *bufpp = (dvoid *) 0;
+ *alenpp = 0;
+ *indpp = (dvoid *) 0;
+ *piecep = OCI_ONE_PIECE;
+
+ return OCI_CONTINUE;
+ }
+ #endif
+
+ /* ----------------------------------------------------------------- */
+
int php3_rinit_oci8(INIT_FUNC_ARGS)
{
OCI8_TLS_VARS;
***************
*** 380,385 ****
--- 403,410 ----
}
if (column->value) {
efree(column->value);
+ column->value = 0;
+
}
return 0;
}
***************
*** 391,414 ****
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);
if (statement->last_query) {
efree(statement->last_query);
- statement->last_query = 0;
}
if (statement->columns) {
_php3_hash_destroy(statement->columns);
efree(statement->columns);
- statement->columns = 0;
}
if (statement->binds) {
_php3_hash_destroy(statement->binds);
efree(statement->binds);
- statement->binds = 0;
}
efree(statement);
}
--- 416,450 ----
oci8_free_stmt(oci8_statement *statement)
{
OCI8_TLS_VARS;
+
+ /*
+ oci8_debug("oci8_free_stmt: id=%d last_query=\"%s\".",statement->id,
+ (char *)(statement->last_query?statement->last_query:"???"));
+ */
+
+ if (statement->pStmt) {
+ OCIHandleFree(statement->pStmt, OCI_HTYPE_STMT);
+ statement->pStmt = 0;
+ }
! if (statement->pError) {
! OCIHandleFree(statement->pError, OCI_HTYPE_ERROR);
! statement->pError = 0;
! }
!
if (statement->last_query) {
efree(statement->last_query);
}
if (statement->columns) {
_php3_hash_destroy(statement->columns);
efree(statement->columns);
}
+
if (statement->binds) {
_php3_hash_destroy(statement->binds);
efree(statement->binds);
}
+
efree(statement);
}
***************
*** 571,583 ****
{
size_t size;
int locator;
pval *value = ecalloc(1,sizeof(pval));
if (column->is_lob) {
object_init(value);
locator = php3_list_insert(column->data, OCI8_GLOBAL(php3_oci8_module).le_lob);
add_property_long(value, "locator", locator);
! add_property_long(value, "statement", stmt_ind);
add_method(value, "save", php3_oci8_savelob);
add_method(value, "load", php3_oci8_loadlob);
} else {
--- 607,622 ----
{
size_t size;
int locator;
+ oci8_statement *statement;
pval *value = ecalloc(1,sizeof(pval));
if (column->is_lob) {
+ statement = oci8_get_stmt(stmt_ind, "oci8_make_pval", list);
+
object_init(value);
locator = php3_list_insert(column->data, OCI8_GLOBAL(php3_oci8_module).le_lob);
add_property_long(value, "locator", locator);
! add_property_long(value, "connection", statement->conn->id);
add_method(value, "save", php3_oci8_savelob);
add_method(value, "load", php3_oci8_loadlob);
} else {
***************
*** 590,596 ****
size = column->size;
break;
case 0: /* intact value */
! size = column->storage_size;
break;
default:
var_reset(value);
--- 629,639 ----
size = column->size;
break;
case 0: /* intact value */
! if ((column->type == SQLT_LBI) || (column->type == SQLT_LNG)) {
! size = strlen(column->data); /*XXX LONGS should be done via callbacks */
! } else {
! size = column->storage_size;
! }
break;
default:
var_reset(value);
***************
*** 621,626 ****
--- 664,670 ----
OCI_HTYPE_STMT, 0, NULL);
OCIHandleAlloc(connection->pEnv, (dvoid **)&statement->pError,
OCI_HTYPE_ERROR, 0, NULL);
+ oci8_debug("oci8_parse \"%s\"",query);
error = oci8_error(statement->pError, "OCIParse",
OCIStmtPrepare(statement->pStmt, connection->pError,
query, len,
***************
*** 631,637 ****
statement->last_query = estrdup(query);
statement->conn = connection;
! return php3_list_insert(statement, OCI8_GLOBAL(php3_oci8_module).le_stmt);
}
/* }}} */
--- 675,688 ----
statement->last_query = estrdup(query);
statement->conn = connection;
! statement->id = php3_list_insert(statement, OCI8_GLOBAL(php3_oci8_module).le_stmt);
!
! /*
! oci8_debug("Added statement (%d) handle for \"%s\".",statement->id,
! (char *)(statement->last_query?statement->last_query:"???"));
! */
!
! return statement->id;
}
/* }}} */
***************
*** 658,664 ****
} else {
iters = 1;
}
! oci8_debug("oci8_execute: stmttype=%d mode=%d", stmttype, mode);
error = OCIStmtExecute(statement->conn->pServiceContext,
statement->pStmt, statement->pError,
iters, 0, NULL, NULL, mode);
--- 709,715 ----
} else {
iters = 1;
}
! /* oci8_debug("oci8_execute: stmttype=%d mode=%d", stmttype, mode); */
error = OCIStmtExecute(statement->conn->pServiceContext,
statement->pStmt, statement->pError,
iters, 0, NULL, NULL, mode);
***************
*** 720,725 ****
--- 771,781 ----
(dvoid **)&outcol->name,
(ub4 *)&outcol->name_len,
(ub4)OCI_ATTR_NAME, statement->pError));
+ { char buffer [ 1024 ];
+ strncpy(buffer,outcol->name,outcol->name_len);
+ buffer[ outcol->name_len ] = 0;
+ printf("%s -> %d\n",buffer,outcol->storage_size);fflush(stdout);
+ }
/* Remember the size Oracle told us, we have to increase the
* storage size for some types.
***************
*** 749,764 ****
(ub2 *)0,
OCI_DEFAULT);
break;
case SQLT_BIN: /* RAW */
- case SQLT_LBI: /* LONG RAW */
case SQLT_RSET: /* ref. cursor */
! outcol->is_opaque = 1;
define_type = outcol->type;
break;
default:
- outcol->is_opaque = 0;
define_type = SQLT_STR;
! outcol->storage_size++; /* add one for string terminator */
outcol->data = (text *)emalloc(outcol->storage_size);
if (outcol->data == NULL) {
--- 805,826 ----
(ub2 *)0,
OCI_DEFAULT);
break;
+
case SQLT_BIN: /* RAW */
case SQLT_RSET: /* ref. cursor */
! /* XXX NYI */
define_type = outcol->type;
break;
+
default:
define_type = SQLT_STR;
!
! if ((outcol->type == SQLT_LBI) || (outcol->type == SQLT_LNG)) {
! outcol->storage_size = (64*1024L)-1; /*XXX LONG fields should be done via callbacks!!! */
! } else {
! outcol->storage_size++; /* add one for string terminator */
! }
!
outcol->data = (text *)emalloc(outcol->storage_size);
if (outcol->data == NULL) {
***************
*** 768,780 ****
return 0;
}
! def_error = OCIDefineByPos(statement->pStmt,
! (OCIDefine **)&outcol->pDefine,
! statement->pError, counter,
! (dvoid *)outcol->data,
! outcol->storage_size, define_type,
! (dvoid *)&outcol->indicator, (ub2 *)0,
! (ub2 *)&outcol->retcode, OCI_DEFAULT);
break;
}
--- 830,847 ----
return 0;
}
! def_error = OCIDefineByPos(
! statement->pStmt, /* IN/OUT handle to the requested SQL query */
! (OCIDefine **)&outcol->pDefine, /* IN/OUT pointer to a pointer to a define
handle */
! statement->pError, /* IN/OUT An error handle */
! counter, /* IN position in the select list */
! (dvoid *)outcol->data, /* IN/OUT pointer to a buffer */
! outcol->storage_size, /* IN The size of each valuep buffer in bytes */
! define_type, /* IN The data type */
! (dvoid *)&outcol->indicator, /* IN pointer to an indicator variable or arr
*/
! (ub2 *)0, /* IN/OUT Pointer to array of length of data fetched */
! (ub2 *)&outcol->retcode, /* OUT Pointer to array of column-level return
codes */
! OCI_DEFAULT); /* IN mode (OCI_DEFAULT, OCI_DYNAMIC_FETCH) */
break;
}
***************
*** 835,874 ****
oci8_bind *phpbind;
pval *val;
! oci8_debug("oci8_bind_in_callback: ictxp=%08x", ictxp);
phpbind = (oci8_bind *)ictxp;
! oci8_debug("oci8_bind_in_callback: phpbind=%08x", phpbind);
if (phpbind) {
oci8_debug("oci8_bind_in_callback: phpbind->val=%08x", phpbind->value);
}
if (!phpbind || !(val = phpbind->value)) {
php3_error(E_WARNING, "!phpbind || !phpbind->val");
return OCI_ERROR;
}
if (val->type == IS_STRING && val->value.str.val == undefined_variable_string) {
/* NULL value */
phpbind->indicator = -1;
! phpbind->size = 0;
! phpbind->buf = NULL;
} else {
! if (phpbind->is_opaque) {
! /* XXX get list entry and return pointer to data */
! /* give NULL value for now */
! phpbind->indicator = -1;
! phpbind->size = 0;
! phpbind->buf = NULL;
! } else {
! convert_to_string(val); /* XXX FIXME should make a copy instead */
! phpbind->indicator = 0;
! phpbind->size = val->value.str.len + 1;
! phpbind->buf = val->value.str.val;
! }
}
! (void)iter; /* ignoring iter */
! (void)index; /* ignoring index */
! *bufpp = phpbind->buf;
! *alenp = phpbind->size;
*indpp = (dvoid *)&phpbind->indicator;
*piecep = OCI_ONE_PIECE; /* pass all data in one go */
--- 902,939 ----
oci8_bind *phpbind;
pval *val;
! /* oci8_debug("oci8_bind_in_callback: ictxp=%08x", ictxp); */
!
phpbind = (oci8_bind *)ictxp;
!
! /* oci8_debug("oci8_bind_in_callback: phpbind=%08x", phpbind);
if (phpbind) {
oci8_debug("oci8_bind_in_callback: phpbind->val=%08x", phpbind->value);
}
+ */
if (!phpbind || !(val = phpbind->value)) {
php3_error(E_WARNING, "!phpbind || !phpbind->val");
return OCI_ERROR;
}
+
+ #if dontneed
if (val->type == IS_STRING && val->value.str.val == undefined_variable_string) {
/* NULL value */
phpbind->indicator = -1;
! phpbind->maxsize = 0;
} else {
! convert_to_string(val); /* XXX FIXME should make a copy instead */
! phpbind->indicator = 0;
! phpbind->maxsize = val->value.str.len + 1;
}
+ #endif
+
+ convert_to_string(val); /* XXX FIXME that's not always our datatype */
+
+ oci8_debug("oci8_bind_in_callback: buffer=\"%s\"
maxlen=%d",val->value.str.val,phpbind->maxsize);
! *bufpp = val->value.str.val;
! *alenp = phpbind->maxsize;
*indpp = (dvoid *)&phpbind->indicator;
*piecep = OCI_ONE_PIECE; /* pass all data in one go */
***************
*** 894,936 ****
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;
}
--- 959,1003 ----
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;
}
!
! /* XXX risky, if the variable has been freed, nasty things
! * could happen here.
! */
!
! if (val->type == IS_OBJECT) {
return OCI_ERROR;
! } else if (val->type == IS_STRING) {
! if (val->value.str.val && (val->value.str.val!=undefined_variable_string)
&& (val->value.str.val!=empty_string)) {
! efree(val->value.str.val); /* free the "old" value */
}
! phpbind->value->value.str.len = phpbind->maxsize;
! phpbind->value->value.str.val = emalloc(phpbind->maxsize);
!
! oci8_debug("oci8_bind_out_callback: maxlen=%d",phpbind->maxsize);
!
! *alenpp = (ub4*) &phpbind->value->value.str.len; /* XXX we assume that php-pval len
has 4 bytes */
! *bufpp = phpbind->value->value.str.val;
*piecep = OCI_ONE_PIECE;
! *rcodepp = &phpbind->rcode;
! *indpp = &phpbind->indicator;
}
!
return OCI_CONTINUE;
}
***************
*** 940,962 ****
/************************* EXTENSION FUNCTIONS *************************/
! /* {{{ proto int OCIBindByName(int stmt, string name, mixed &var)
Bind a PHP variable to an Oracle placeholder by name.
*/
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;
--- 1007,1059 ----
/************************* EXTENSION FUNCTIONS *************************/
! /* {{{ proto int OCIBindByName(int stmt, string name, mixed &var, int maxlength [, int
type])
Bind a PHP variable to an Oracle placeholder by name.
*/
void php3_oci8_bindbyname(INTERNAL_FUNCTION_PARAMETERS)
{
! pval *stmt, *name, *var, *maxlen, *type;
oci8_statement *statement;
oci8_bind *bind, *tmp_bind;
sword error;
+ ub2 ocitype;
+ sb4 ocimaxlen;
+
+ ocitype = SQLT_STR;
! if (getParameters(ht, 5, &stmt, &name, &var, &maxlen, &type) == SUCCESS) {
! convert_to_long(maxlen);
! convert_to_long(type);
! ocimaxlen = maxlen->value.lval;
! ocitype = type->value.lval;
! } else if (getParameters(ht, 4, &stmt, &name, &var, &maxlen) == SUCCESS) {
! convert_to_long(maxlen);
! ocimaxlen = maxlen->value.lval;
! } else {
WRONG_PARAM_COUNT;
}
+
+ switch (ocitype) {
+ case SQLT_BLOB :
+ case SQLT_CLOB :
+ if (var->type != IS_OBJECT) {
+ php3_error(E_WARNING, "OCIBindByName LOBs must be initializes using OCINewLob!");
+ RETURN_FALSE;
+ }
+ break;
+
+ default:
+ convert_to_string(var);
+ if (ocimaxlen == -1) {
+ ocimaxlen = var->value.str.len;
+ }
+ break;
+ }
+ ocimaxlen++;
convert_to_long(stmt);
convert_to_string(name);
!
statement = oci8_get_stmt(stmt->value.lval, "OCIBindByName", list);
if (statement == NULL) {
RETURN_FALSE;
***************
*** 980,994 ****
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) */
--- 1077,1094 ----
efree(bind);
bind = tmp_bind;
}
+
bind->value = var;
+ bind->maxsize = ocimaxlen;
+
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 */
! ocimaxlen, /* max size of input/output data */
! (ub2)ocitype, /* in/out data type */
(dvoid *)0, /* indicator (ignored) */
(ub2 *)0, /* size array (ignored) */
(ub2 *)0, /* return code (ignored) */
***************
*** 1002,1011 ****
error = OCIBindDynamic(bind->pBind,
statement->pError,
(dvoid *)bind,
! oci8_bind_in_callback,
(dvoid *)bind,
! oci8_bind_out_callback
! );
RETVAL_TRUE;
}
--- 1102,1110 ----
error = OCIBindDynamic(bind->pBind,
statement->pError,
(dvoid *)bind,
! /* cbf_no_data*/ oci8_bind_in_callback,
(dvoid *)bind,
! oci8_bind_out_callback);
RETVAL_TRUE;
}
***************
*** 1015,1038 ****
void php3_oci8_savelob(INTERNAL_FUNCTION_PARAMETERS)
{
! pval *id, *tmp, *stmt, *arg;
int id_to_find;
int lob_type;
OCILobLocator *mylob;
! oci8_statement *statement;
sword ociresult;
ub4 loblen;
OCI8_TLS_VARS;
if (getThis(&id) == SUCCESS) {
! if (_php3_hash_find(id->value.ht, "statement", sizeof("statement"),
(void **)&stmt) == FAILURE) {
php3_error(E_WARNING, "unable to find my statement property");
RETURN_FALSE;
}
! statement = oci8_get_stmt(stmt->value.lval, "OCISaveLob", list);
! if (statement == NULL) {
RETURN_FALSE;
}
--- 1114,1137 ----
void php3_oci8_savelob(INTERNAL_FUNCTION_PARAMETERS)
{
! pval *id, *tmp, *conn, *arg;
int id_to_find;
int lob_type;
OCILobLocator *mylob;
! oci8_connection *connection;
sword ociresult;
ub4 loblen;
OCI8_TLS_VARS;
if (getThis(&id) == SUCCESS) {
! if (_php3_hash_find(id->value.ht, "connection", sizeof("connection"),
(void **)&conn) == FAILURE) {
php3_error(E_WARNING, "unable to find my statement property");
RETURN_FALSE;
}
! connection = oci8_get_conn(conn->value.lval, "OCISaveLob", list, plist);
! if (connection == NULL) {
RETURN_FALSE;
}
***************
*** 1055,1062 ****
loblen = arg->value.str.len;
! ociresult = OCILobWrite(statement->conn->pServiceContext,
! statement->conn->pError,
mylob,
&loblen,
(ub4) 1,
--- 1154,1161 ----
loblen = arg->value.str.len;
! ociresult = OCILobWrite(connection->pServiceContext,
! connection->pError,
mylob,
&loblen,
(ub4) 1,
***************
*** 1069,1075 ****
(ub1) SQLCS_IMPLICIT);
if (ociresult) {
! oci8_error(statement->conn->pError, "OCILobWrite", ociresult);
RETURN_FALSE;
}
--- 1168,1174 ----
(ub1) SQLCS_IMPLICIT);
if (ociresult) {
! oci8_error(connection->pError, "OCILobWrite", ociresult);
RETURN_FALSE;
}
***************
*** 1085,1095 ****
void php3_oci8_loadlob(INTERNAL_FUNCTION_PARAMETERS)
{
! pval *id, *tmp, *stmt;
int id_to_find;
int lob_type;
OCILobLocator *mylob;
! oci8_statement *statement;
sword ociresult;
char *buffer;
ub4 loblen;
--- 1184,1194 ----
void php3_oci8_loadlob(INTERNAL_FUNCTION_PARAMETERS)
{
! pval *id, *tmp, *conn;
int id_to_find;
int lob_type;
OCILobLocator *mylob;
! oci8_connection *connection;
sword ociresult;
char *buffer;
ub4 loblen;
***************
*** 1097,1109 ****
OCI8_TLS_VARS;
if (getThis(&id) == SUCCESS) {
! if (_php3_hash_find(id->value.ht, "statement", sizeof("statement"),
(void **)&stmt) == FAILURE) {
! php3_error(E_WARNING, "unable to find my statement property");
RETURN_FALSE;
}
! statement = oci8_get_stmt(stmt->value.lval, "OCILoadLob", list);
! if (statement == NULL) {
RETURN_FALSE;
}
--- 1196,1208 ----
OCI8_TLS_VARS;
if (getThis(&id) == SUCCESS) {
! if (_php3_hash_find(id->value.ht, "connection", sizeof("connection"),
(void **)&conn) == FAILURE) {
! php3_error(E_WARNING, "unable to find my connection property");
RETURN_FALSE;
}
! connection = oci8_get_conn(conn->value.lval, "OCILoadLob", list, plist);
! if (connection == NULL) {
RETURN_FALSE;
}
***************
*** 1120,1129 ****
RETURN_FALSE;
}
! ociresult = OCILobGetLength(statement->conn->pServiceContext,
statement->conn->pError, mylob, &loblen);
if (ociresult) {
! oci8_error(statement->conn->pError, "OCILobGetLength", ociresult);
RETURN_FALSE;
}
--- 1219,1228 ----
RETURN_FALSE;
}
! ociresult = OCILobGetLength(connection->pServiceContext, connection->pError, mylob,
&loblen);
if (ociresult) {
! oci8_error(connection->pError, "OCILobGetLength", ociresult);
RETURN_FALSE;
}
***************
*** 1132,1139 ****
RETURN_FALSE;
}
! ociresult = OCILobRead(statement->conn->pServiceContext,
! statement->conn->pError,
mylob,
&loblen, /* IN/OUT bytes toread/read */
1, /* offset (starts with 1) */
--- 1231,1238 ----
RETURN_FALSE;
}
! ociresult = OCILobRead(connection->pServiceContext,
! connection->pError,
mylob,
&loblen, /* IN/OUT bytes toread/read */
1, /* offset (starts with 1) */
***************
*** 1145,1151 ****
(ub1) SQLCS_IMPLICIT); /* The character set form of the buffer data. */
if (ociresult) {
! oci8_error(statement->conn->pError, "OCILobRead", ociresult);
efree(buffer);
RETURN_FALSE;
}
--- 1244,1250 ----
(ub1) SQLCS_IMPLICIT); /* The character set form of the buffer data. */
if (ociresult) {
! oci8_error(connection->pError, "OCILobRead", ociresult);
efree(buffer);
RETURN_FALSE;
}
***************
*** 1157,1162 ****
--- 1256,1299 ----
}
/* }}} */
+ /* {{{ proto string OCINewLob(int connection)
+ initialize a new empty lob
+ */
+
+ void php3_oci8_newlob(INTERNAL_FUNCTION_PARAMETERS)
+ {
+ pval *conn;
+ sword ociresult;
+ oci8_connection *connection;
+ OCILobLocator *mylob;
+ int locator;
+ OCI8_TLS_VARS;
+
+ if (getParameters(ht, 1, &conn) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_long(conn);
+
+ connection = oci8_get_conn(conn->value.lval, "OCINewLob", list, plist);
+ if (connection == NULL) {
+ RETURN_FALSE;
+ }
+
+ ociresult = OCIDescriptorAlloc(connection->pEnv,(dvoid*)&(mylob), OCI_DTYPE_LOB, (size_t)
0, (dvoid **) 0);
+
+ if (ociresult) {
+ oci8_error(connection->pError,"OCIDescriptorAlloc OCI_DTYPE_LOB",ociresult);
+ RETURN_FALSE;
+ }
+
+ object_init(return_value);
+ locator = php3_list_insert(mylob, OCI8_GLOBAL(php3_oci8_module).le_lob);
+ add_property_long(return_value, "locator", locator);
+ add_property_long(return_value, "connection", conn->value.lval);
+ add_method(return_value, "save", php3_oci8_savelob);
+ add_method(return_value, "load", php3_oci8_loadlob);
+ }
+
/* {{{ proto string OCIRollback(int stmt)
rollback the current context
*/
***************
*** 1516,1522 ****
if (statement == NULL) {
RETURN_FALSE;
}
! oci8_free_stmt(statement);
RETVAL_TRUE;
}
--- 1653,1661 ----
if (statement == NULL) {
RETURN_FALSE;
}
!
! php3_list_delete(stmt->value.lval);
!
RETVAL_TRUE;
}
***************
*** 1652,1676 ****
RETURN_FALSE;
}
-
- /*
-
- 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++;
}
--- 1791,1803 ----
RETURN_FALSE;
}
connection->open = 1;
/* non persistent, simply add to list */
! connection->id = php3_list_insert(connection, OCI8_GLOBAL(php3_oci8_module).le_conn);
!
! RETVAL_LONG(connection->id);
!
OCI8_GLOBAL(php3_oci8_module).num_links++;
}
Index: php3/functions/php3_oci8.h
diff -c php3/functions/php3_oci8.h:1.15 php3/functions/php3_oci8.h:1.16
*** php3/functions/php3_oci8.h:1.15 Wed Feb 3 13:21:02 1999
--- php3/functions/php3_oci8.h Mon Feb 8 06:30:22 1999
***************
*** 58,63 ****
--- 58,64 ----
# endif
typedef struct {
+ int id;
OCIEnv *pEnv;
OCIServer *pServer;
OCISvcCtx *pServiceContext;
***************
*** 67,72 ****
--- 68,74 ----
} oci8_connection;
typedef struct {
+ int id;
oci8_connection *conn;
OCIError *pError;
OCIStmt *pStmt;
***************
*** 79,88 ****
typedef struct {
OCIBind *pBind;
pval *value;
! ub4 size;
! dvoid *buf;
sb2 indicator;
- ub2 is_opaque;
ub2 rcode;
} oci8_bind;
--- 81,88 ----
typedef struct {
OCIBind *pBind;
pval *value;
! ub4 maxsize;
sb2 indicator;
ub2 rcode;
} oci8_bind;
***************
*** 96,102 ****
void *data;
sb2 indicator;
ub2 retcode;
- ub2 is_opaque;
ub2 is_lob;
pval *value;
} oci8_out_column;
--- 96,101 ----
***************
*** 115,121 ****
int le_lob;
/* int le_pconn;*/
int le_stmt;
! sb4 max_bind_data_size;
} oci8_module;
extern php3_module_entry oci8_module_entry;
--- 114,120 ----
int le_lob;
/* int le_pconn;*/
int le_stmt;
! /* sb4 max_bind_data_size; */
} oci8_module;
extern php3_module_entry oci8_module_entry;
--
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