CVS update: php3/functions
| From: | thies | Date: | Fri, 08 Jan 1999 12:47:08 +0000 |
| Subject: | CVS update: php3/functions | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-3397@lists.php.net to get a copy of this message | ||
Date: Friday January 8, 1999 @ 7:47
Author: thies
Update of /repository/php3/functions
In directory asf:/u/temp/cvs-serv23349/functions
Modified Files:
oracle.c
Log Message:
added optional 3th parameter to ora_fetchinto (some flags).
added php3 constants:
ORA_FETCHINTO_ASSOC: return an assoc array instead of an indexed one (default indexed)
ORA_FETCHINTO_NULLS: return NULL fields (default don't return them)
this change is fully backward compatibe (but nice;-)!
Index: php3/functions/oracle.c
diff -c php3/functions/oracle.c:1.92 php3/functions/oracle.c:1.93
*** php3/functions/oracle.c:1.92 Wed Jan 6 09:45:44 1999
--- php3/functions/oracle.c Fri Jan 8 07:47:07 1999
***************
*** 30,36 ****
+----------------------------------------------------------------------+
*/
! /* $Id: oracle.c,v 1.92 1999/01/06 14:45:44 thies Exp $ */
#if defined(COMPILE_DL)
# if PHP_31
--- 30,36 ----
+----------------------------------------------------------------------+
*/
! /* $Id: oracle.c,v 1.93 1999/01/08 12:47:07 thies Exp $ */
#if defined(COMPILE_DL)
# if PHP_31
***************
*** 82,87 ****
--- 82,90 ----
#define DB_SIZE 65536
+ #define ORA_FETCHINTO_ASSOC (1<<0)
+ #define ORA_FETCHINTO_NULLS (1<<1)
+
static oraConnection *ora_get_conn(HashTable *, int);
static int ora_add_cursor(HashTable *, oraCursor *);
static oraCursor *ora_get_cursor(HashTable *, int);
***************
*** 301,306 ****
--- 304,312 ----
REGISTER_LONG_CONSTANT("ORA_BIND_IN", 1, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("ORA_BIND_OUT", 2, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("ORA_FETCHINTO_ASSOC",ORA_FETCHINTO_ASSOC, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("ORA_FETCHINTO_NULLS",ORA_FETCHINTO_NULLS, CONST_CS |
CONST_PERSISTENT);
+
return SUCCESS;
}
***************
*** 1062,1078 ****
}
/* }}} */
! /* {{{ proto int ora_fetch_into(int cursor, array result)
Fetch a row into the specified result array */
void php3_Ora_FetchInto(INTERNAL_FUNCTION_PARAMETERS)
! { /* cursor_index, array ref */
! pval *arg1, *arr, tmp;
oraCursor *cursor;
ub4 ret_len;
int i;
! if (getParameters(ht, 2, &arg1, &arr) == FAILURE) {
! WRONG_PARAM_COUNT;
}
if (!ParameterPassedByReference(ht, 2)){
--- 1068,1101 ----
}
/* }}} */
! /* {{{ proto int ora_fetch_into(int cursor, array result [ , int flags ])
Fetch a row into the specified result array */
void php3_Ora_FetchInto(INTERNAL_FUNCTION_PARAMETERS)
! {
! pval *arg1, *arr, *flg, tmp;
oraCursor *cursor;
ub4 ret_len;
int i;
+ int flags = 0;
! switch(ARG_COUNT(ht)){
! case 2:
! if (getParameters(ht, 2, &arg1, &arr) == FAILURE) {
! WRONG_PARAM_COUNT;
! }
! break;
!
! case 3:
! if (getParameters(ht, 3, &arg1, &arr, &flg) == FAILURE) {
! WRONG_PARAM_COUNT;
! }
! convert_to_long(flg);
! flags = flg->value.lval;
! break;
!
! default:
! WRONG_PARAM_COUNT;
! break;
}
if (!ParameterPassedByReference(ht, 2)){
***************
*** 1113,1119 ****
tmp.value.str.len = 0;
if (cursor->columns[i].col_retcode == 1405) {
! continue; /* don't add anything for NULL columns */
} else if (cursor->columns[i].col_retcode != 0 &&
cursor->columns[i].col_retcode != 1406) {
/* So error fetching column. The most common is 1405, a NULL */
--- 1136,1147 ----
tmp.value.str.len = 0;
if (cursor->columns[i].col_retcode == 1405) {
! if (!(flags&ORA_FETCHINTO_NULLS)){
! continue; /* don't add anything for NULL columns, unless the calles wants it */
! } else {
! tmp.value.str.val = empty_string;
! tmp.value.str.len = 0;
! }
} else if (cursor->columns[i].col_retcode != 0 &&
cursor->columns[i].col_retcode != 1406) {
/* So error fetching column. The most common is 1405, a NULL */
***************
*** 1139,1146 ****
}
tmp.value.str.val = estrndup(cursor->columns[i].buf,
tmp.value.str.len);
}
! _php3_hash_index_update(arr->value.ht, i, (void *) &tmp, sizeof(pval), NULL);
}
RETURN_LONG(cursor->ncols);
--- 1167,1180 ----
}
tmp.value.str.val = estrndup(cursor->columns[i].buf,
tmp.value.str.len);
+ }
+
+ if (flags&ORA_FETCHINTO_ASSOC){
+ _php3_hash_update(arr->value.ht, cursor->columns[i].cbuf, cursor->columns[i].cbufl+1,
(void *) &tmp, sizeof(pval), NULL);
+ } else {
+ _php3_hash_index_update(arr->value.ht, i, (void *) &tmp, sizeof(pval), NULL);
}
!
}
RETURN_LONG(cursor->ncols);
--
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