CVS update: php3/functions
| From: | thies | Date: | Fri, 12 Feb 1999 12:21:09 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-4065@lists.php.net to get a copy of this message | ||
Date: Friday February 12, 1999 @ 7:21
Author: thies
Update of /repository/php3/functions
In directory asf:/u/temp/cvs-serv15147/functions
Modified Files:
oci8.c php3_oci8.h
Log Message:
added OCIFlags(int conn [, int flags])
- OCI_RETURN_NULLS (OCIResult, OCIFetchInto will return an empty instead of an undefined string for
NULL columns)
Index: php3/functions/oci8.c
diff -c php3/functions/oci8.c:1.40 php3/functions/oci8.c:1.41
*** php3/functions/oci8.c:1.40 Fri Feb 12 03:47:58 1999
--- php3/functions/oci8.c Fri Feb 12 07:21:08 1999
***************
*** 32,38 ****
+----------------------------------------------------------------------+
*/
! /* $Id: oci8.c,v 1.40 1999/02/12 08:47:58 thies Exp $ */
#include "php.h"
#include "internal_functions.h"
--- 32,38 ----
+----------------------------------------------------------------------+
*/
! /* $Id: oci8.c,v 1.41 1999/02/12 12:21:08 thies Exp $ */
#include "php.h"
#include "internal_functions.h"
***************
*** 170,175 ****
--- 170,176 ----
void php3_oci8_numcols(INTERNAL_FUNCTION_PARAMETERS);
void php3_oci8_parse(INTERNAL_FUNCTION_PARAMETERS);
void php3_oci8_result(INTERNAL_FUNCTION_PARAMETERS);
+ void php3_oci8_flags(INTERNAL_FUNCTION_PARAMETERS);
void php3_oci8_serverversion(INTERNAL_FUNCTION_PARAMETERS);
void php3_oci8_statementtype(INTERNAL_FUNCTION_PARAMETERS);
***************
*** 178,186 ****
static unsigned char refs_aaf[] = {3, BYREF_ALLOW, BYREF_ALLOW, BYREF_FORCE};
! #define OCI_ASSOC 1<<0
! #define OCI_NUM 1<<1
! #define OCI_BOTH (OCI_ASSOC|OCI_NUM)
function_entry oci8_functions[] = {
{"ocibindbyname", php3_oci8_bindbyname, refs_aaf},
--- 179,188 ----
static unsigned char refs_aaf[] = {3, BYREF_ALLOW, BYREF_ALLOW, BYREF_FORCE};
! #define OCI_ASSOC 1<<0
! #define OCI_NUM 1<<1
! #define OCI_RETURN_NULLS 1<<2
! #define OCI_BOTH (OCI_ASSOC|OCI_NUM)
function_entry oci8_functions[] = {
{"ocibindbyname", php3_oci8_bindbyname, refs_aaf},
***************
*** 194,199 ****
--- 196,202 ----
{"ocifreestatement", php3_oci8_freestatement, NULL},
{"ociinternaldebug", php3_oci8_internaldebug, NULL},
{"ocinumcols", php3_oci8_numcols, NULL},
+ {"ociflags", php3_oci8_flags, NULL},
{"ociparse", php3_oci8_parse, NULL},
{"ociresult", php3_oci8_result, NULL},
{"ociserverversion", php3_oci8_serverversion, NULL},
***************
*** 287,296 ****
REGISTER_LONG_CONSTANT("SQLT_CLOB",SQLT_CLOB, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SQLT_BLOB",SQLT_BLOB, CONST_CS | CONST_PERSISTENT);
! /* for OCIFetchInto */
REGISTER_LONG_CONSTANT("OCI_ASSOC",OCI_ASSOC, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OCI_NUM",OCI_NUM, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OCI_BOTH",OCI_BOTH, CONST_CS | CONST_PERSISTENT);
return SUCCESS;
}
--- 290,300 ----
REGISTER_LONG_CONSTANT("SQLT_CLOB",SQLT_CLOB, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SQLT_BLOB",SQLT_BLOB, CONST_CS | CONST_PERSISTENT);
! /* for OCIFetchInto & OCIFlags */
REGISTER_LONG_CONSTANT("OCI_ASSOC",OCI_ASSOC, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OCI_NUM",OCI_NUM, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OCI_BOTH",OCI_BOTH, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("OCI_RETURN_NULLS",OCI_RETURN_NULLS, CONST_CS |
CONST_PERSISTENT);
return SUCCESS;
}
***************
*** 638,643 ****
--- 642,648 ----
{
size_t size;
pval *value;
+ int flags;
oci8_statement *statement;
if (val) {
***************
*** 648,655 ****
memset(value,0,sizeof(pval));
if (column->is_descr) {
- statement = oci8_get_stmt(stmt_ind, "oci8_make_pval", list);
object_init(value);
add_property_long(value, "connection", statement->conn->id);
--- 653,663 ----
memset(value,0,sizeof(pval));
+ statement = oci8_get_stmt(stmt_ind, "oci8_make_pval", list);
+
+ flags = statement->conn->flags;
+
if (column->is_descr) {
object_init(value);
add_property_long(value, "connection", statement->conn->id);
***************
*** 658,675 ****
add_method(value, "load", php3_oci8_loadlob);
} else {
switch (column->indicator) {
- case -1: /* NULL value, return an empty string */
- var_reset(value);
- return value;
case -2: /* truncated value */
oci8_debug("%s: truncated column", func);
size = column->size;
break;
case 0: /* intact value */
size = strlen(column->data); /* everything is now a NULL terminated string */
break;
! default:
! var_reset(value);
return value;
}
--- 666,690 ----
add_method(value, "load", php3_oci8_loadlob);
} else {
switch (column->indicator) {
case -2: /* truncated value */
oci8_debug("%s: truncated column", func);
size = column->size;
break;
+
+
case 0: /* intact value */
size = strlen(column->data); /* everything is now a NULL terminated string */
break;
!
! case -1: /* we hit a NULL value, return empty string or uninitialized value */
! default: /* XXX we SHOULD maybe have a different behaviour for unknown results! */
! if (flags & OCI_RETURN_NULLS) { /* OCI_RETURN_NULLS means that we ALWAYS want to get
"at least" an empty string */
! value->type = IS_STRING;
! value->value.str.len = 0;
! value->value.str.val = empty_string;
! } else {
! var_reset(value);
! }
return value;
}
***************
*** 795,801 ****
/* get column name */
oci8_error(statement->pError, "OCIAttrGet(param,name)",
OCIAttrGet((dvoid *)param, OCI_DTYPE_PARAM,
! (dvoid **)&outcol->name,
(ub4 *)&outcol->name_len,
(ub4)OCI_ATTR_NAME, statement->pError));
--- 810,816 ----
/* get column name */
oci8_error(statement->pError, "OCIAttrGet(param,name)",
OCIAttrGet((dvoid *)param, OCI_DTYPE_PARAM,
! (dvoid **)&outcol->name, /* XXX this string is NOT zero terminated!!!! */
(ub4 *)&outcol->name_len,
(ub4)OCI_ATTR_NAME, statement->pError));
***************
*** 1755,1761 ****
for (i = 0; i < statement->ncolumns; i++) {
column = oci8_get_col(statement, i + 1, 0, "OCIFetchInto");
! if (column == NULL || column->indicator == -1) {
continue;
}
--- 1770,1780 ----
for (i = 0; i < statement->ncolumns; i++) {
column = oci8_get_col(statement, i + 1, 0, "OCIFetchInto");
! if (column == NULL) { /* should not happen... */
! continue;
! }
!
! if ((column->indicator == -1) && (! statement->conn->flags &
OCI_RETURN_NULLS)) {
continue;
}
***************
*** 1996,2003 ****
} else {
RETURN_FALSE;
}
-
-
}
/* }}} */
--- 2015,2020 ----
***************
*** 2049,2054 ****
--- 2066,2110 ----
query->value.str.val,
query->value.str.len,
list));
+ }
+
+ /* }}} */
+ /* {{{ proto string OCIFlags(int connection [, int flags])
+ Sets operation-mode returning the old one
+ */
+
+ void php3_oci8_flags(INTERNAL_FUNCTION_PARAMETERS)
+ {
+ pval *conn, *flags;
+ oci8_connection *connection;
+ int oldflags;
+ int setflags;
+ int doset = 0;
+ OCI8_TLS_VARS;
+
+ if (getParameters(ht, 2, &conn, &flags) == SUCCESS) {
+ convert_to_long(flags);
+ setflags = flags->value.lval;
+ doset = 1;
+ } else if (getParameters(ht, 2, &conn) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_long(conn);
+
+ connection = oci8_get_conn(conn->value.lval, "OCIFlags", list, plist);
+
+ if (connection == NULL) {
+ RETURN_FALSE;
+ }
+
+ oldflags = connection->flags;
+
+ if (doset) {
+ connection->flags = setflags;
+ }
+
+ RETURN_LONG(oldflags);
}
/* }}} */
Index: php3/functions/php3_oci8.h
diff -c php3/functions/php3_oci8.h:1.22 php3/functions/php3_oci8.h:1.23
*** php3/functions/php3_oci8.h:1.22 Fri Feb 12 03:47:58 1999
--- php3/functions/php3_oci8.h Fri Feb 12 07:21:08 1999
***************
*** 67,72 ****
--- 67,73 ----
HashTable *descriptors;
int descriptors_count;
int open;
+ int flags;
} oci8_connection;
typedef struct {
--
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