CVS update: php3/functions

From: Date: Tue, 09 Mar 1999 16:27:16 +0000
Subject: CVS update: php3/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-4546@lists.php.net to get a copy of this message
Date: Tuesday March 9, 1999 @ 11:27 Author: thies Update of /repository/php3/functions In directory asf:/u/temp/cvs-serv21267 Modified Files: oci8.c Log Message: added OCIFetchStatement (fetches the whole statement) - needs some flags for different behaviours... Index: php3/functions/oci8.c diff -c php3/functions/oci8.c:1.66 php3/functions/oci8.c:1.67 *** php3/functions/oci8.c:1.66 Thu Feb 25 07:14:09 1999 --- php3/functions/oci8.c Tue Mar 9 11:27:15 1999 *************** *** 33,39 **** #define OCI8_USE_EMALLOC 0 /* set this to 1 if you want to use the php memory manager! */ ! /* $Id: oci8.c,v 1.66 1999/02/25 12:14:09 thies Exp $ */ /* TODO list: * --- 33,39 ---- #define OCI8_USE_EMALLOC 0 /* set this to 1 if you want to use the php memory manager! */ ! /* $Id: oci8.c,v 1.67 1999/03/09 16:27:15 thies Exp $ */ /* TODO list: * *************** *** 57,62 **** --- 57,63 ---- * this seems to happen for NUMBER values only... * - make OCIInternalDebug accept a mask of flags.... * - better NULL handling + * - add some flags to OCIFetchStatement (maxrows etc...) */ /* {{{ includes & stuff */ *************** *** 176,181 **** --- 177,183 ---- void php3_oci8_execute(INTERNAL_FUNCTION_PARAMETERS); void php3_oci8_fetch(INTERNAL_FUNCTION_PARAMETERS); void php3_oci8_fetchinto(INTERNAL_FUNCTION_PARAMETERS); + void php3_oci8_fetchstatement(INTERNAL_FUNCTION_PARAMETERS); void php3_oci8_freestatement(INTERNAL_FUNCTION_PARAMETERS); void php3_oci8_internaldebug(INTERNAL_FUNCTION_PARAMETERS); void php3_oci8_logoff(INTERNAL_FUNCTION_PARAMETERS); *************** *** 217,222 **** --- 219,225 ---- {"ociexecute", php3_oci8_execute, NULL}, {"ocifetch", php3_oci8_fetch, NULL}, {"ocifetchinto", php3_oci8_fetchinto, a2_arg_force_ref}, + {"ocifetchstatement",php3_oci8_fetchstatement,a2_arg_force_ref}, {"ocifreestatement", php3_oci8_freestatement, NULL}, {"ociinternaldebug", php3_oci8_internaldebug, NULL}, {"ocinumcols", php3_oci8_numcols, NULL}, *************** *** 228,236 **** {"ocilogoff", php3_oci8_logoff, NULL}, {"ocilogon", php3_oci8_logon, NULL}, {"ocierror", php3_oci8_error, NULL}, ! {"ocifreedescriptor",php3_oci8_freedesc, NULL}, ! {"ocisavedesc", php3_oci8_savedesc, NULL}, ! {"ociloaddesc", php3_oci8_loaddesc, NULL}, {"ocicommit", php3_oci8_commit, NULL}, {"ocirollback", php3_oci8_rollback, NULL}, {"ocinewdescriptor", php3_oci8_newdescriptor, NULL}, --- 231,239 ---- {"ocilogoff", php3_oci8_logoff, NULL}, {"ocilogon", php3_oci8_logon, NULL}, {"ocierror", php3_oci8_error, NULL}, ! {"ocifreedescriptor",php3_oci8_freedesc, NULL}, ! {"ocisavedesc", php3_oci8_savedesc, NULL}, ! {"ociloaddesc", php3_oci8_loaddesc, NULL}, {"ocicommit", php3_oci8_commit, NULL}, {"ocirollback", php3_oci8_rollback, NULL}, {"ocinewdescriptor", php3_oci8_newdescriptor, NULL}, *************** *** 2176,2181 **** --- 2179,2251 ---- } RETVAL_LONG(statement->ncolumns); + } + + /* }}} */ + /* {{{ proto int OCIFetchStatement(int stmt, array &output) + Fetch all rows of result data into an array. + */ + + void php3_oci8_fetchstatement(INTERNAL_FUNCTION_PARAMETERS) + { + pval *stmt, *array, element, *fmode; + oci8_statement *statement; + oci8_out_column **columns; + pval **outarrs; + pval tmp; + ub4 nrows = 1; + int i; + int mode = OCI_NUM; + int rows = 0; + char namebuf[ 128 ]; + OCI8_TLS_VARS; + + if (getParameters(ht, 3, &stmt, &array, &fmode) == SUCCESS) { + convert_to_long(fmode); + mode = fmode->value.lval; + } else if (getParameters(ht, 2, &stmt, &array) == FAILURE) { + WRONG_PARAM_COUNT; + } + + convert_to_long(stmt); + statement = oci8_get_stmt(stmt->value.lval, "OCIFetchStatement", list); + if (statement == NULL) { + RETURN_FALSE; + } + + if (array->type != IS_ARRAY) { + if (array_init(array) == FAILURE) { + php3_error(E_WARNING, "OCIFetchStatement: unable to convert arg 2 to array"); + RETURN_FALSE; + } + } + + columns = emalloc(statement->ncolumns * sizeof(oci8_out_column *)); + outarrs = emalloc(statement->ncolumns * sizeof(pval)); + + for (i = 0; i < statement->ncolumns; i++) { + columns[ i ] = oci8_get_col(statement, i + 1, 0, "OCIFetchStatement"); + + array_init(&tmp); + + memcpy(namebuf,columns[ i ]->name, columns[ i ]->name_len); + namebuf[ columns[ i ]->name_len ] = 0; + + _php3_hash_update(array->value.ht, namebuf, columns[ i ]->name_len+1, (void *) &tmp, sizeof(pval), (void **) &(outarrs[ i ])); + } + + while (oci8_fetch(statement, nrows, "OCIFetchStatement")) { + for (i = 0; i < statement->ncolumns; i++) { + oci8_make_pval(&element,stmt->value.lval,columns[ i ], "OCIFetchStatement",list,OCI_RETURN_LOBS); + _php3_hash_index_update(outarrs[ i ]->value.ht, rows, (void *)&element, sizeof(pval), NULL); + } + rows++; + } + + efree(columns); + efree(outarrs); + + RETVAL_LONG(rows); } /* }}} */ -- 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 (#4546) next »