cvs: php4 /ext/fbsql php_fbsql.c php_fbsql.h

From: Date: Tue, 17 Apr 2001 17:39:43 +0000
Subject: cvs: php4 /ext/fbsql php_fbsql.c php_fbsql.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-5147@lists.php.net to get a copy of this message
fmk Tue Apr 17 10:39:43 2001 EDT Modified files: /php4/ext/fbsql php_fbsql.h php_fbsql.c Log: Adding fbsql_fetch_assoc() functon Index: php4/ext/fbsql/php_fbsql.h diff -u php4/ext/fbsql/php_fbsql.h:1.2 php4/ext/fbsql/php_fbsql.h:1.3 --- php4/ext/fbsql/php_fbsql.h:1.2 Wed Apr 4 13:10:14 2001 +++ php4/ext/fbsql/php_fbsql.h Tue Apr 17 10:39:43 2001 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_fbsql.h,v 1.2 2001/04/04 20:10:14 fmk Exp $ */ +/* $Id: php_fbsql.h,v 1.3 2001/04/17 17:39:43 fmk Exp $ */ #define HAVE_FBSQL 1 @@ -67,6 +67,7 @@ PHP_FUNCTION(fbsql_num_fields); PHP_FUNCTION(fbsql_fetch_row); PHP_FUNCTION(fbsql_fetch_array); +PHP_FUNCTION(fbsql_fetch_assoc); PHP_FUNCTION(fbsql_fetch_object); PHP_FUNCTION(fbsql_data_seek); PHP_FUNCTION(fbsql_fetch_lengths); @@ -87,6 +88,8 @@ PHP_FUNCTION(fbsql_username); PHP_FUNCTION(fbsql_password); PHP_FUNCTION(fbsql_warnings); + +static void php_fbsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type); ZEND_BEGIN_MODULE_GLOBALS(fbsql) long allowPersistent; Index: php4/ext/fbsql/php_fbsql.c diff -u php4/ext/fbsql/php_fbsql.c:1.11 php4/ext/fbsql/php_fbsql.c:1.12 --- php4/ext/fbsql/php_fbsql.c:1.11 Mon Apr 16 09:27:11 2001 +++ php4/ext/fbsql/php_fbsql.c Tue Apr 17 10:39:43 2001 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_fbsql.c,v 1.11 2001/04/16 16:27:11 fmk Exp $ */ +/* $Id: php_fbsql.c,v 1.12 2001/04/17 17:39:43 fmk Exp $ */ /* TODO: * @@ -201,6 +201,7 @@ PHP_FE(fbsql_num_fields, NULL) PHP_FE(fbsql_fetch_row, NULL) PHP_FE(fbsql_fetch_array, NULL) + PHP_FE(fbsql_fetch_assoc, NULL) PHP_FE(fbsql_fetch_object, NULL) PHP_FE(fbsql_data_seek, NULL) PHP_FE(fbsql_fetch_lengths, NULL) @@ -2523,11 +2524,29 @@ /* }}} */ -/* {{{ proto object fbsql_fetch_object(int result [, int result_typ]) +/* {{{ proto array fbsql_fetch_row(int result) + */ +PHP_FUNCTION(fbsql_fetch_row) +{ + php_fbsql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, FBSQL_NUM); +} +/* }}} */ + + +/* {{{ proto object fbsql_fetch_assoc(int result) */ +PHP_FUNCTION(fbsql_fetch_assoc) +{ + php_fbsql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, FBSQL_ASSOC); +} +/* }}} */ + + +/* {{{ proto object fbsql_fetch_object(int result [, int result_type]) + */ PHP_FUNCTION(fbsql_fetch_object) { - PHP_FN(fbsql_fetch_array)(INTERNAL_FUNCTION_PARAM_PASSTHRU); + php_fbsql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, FBSQL_ASSOC); if (return_value->type==IS_ARRAY) { return_value->type=IS_OBJECT; @@ -2538,72 +2557,15 @@ /* }}} */ -/* {{{ proto array fbsql_fetch_row(int result) - */ -PHP_FUNCTION(fbsql_fetch_row) +/* {{{ proto array fbsql_fetch_array(int result [, int result_type]) + Fetch a result row as an array (associative, numeric or both)*/ +PHP_FUNCTION(fbsql_fetch_array) { - int argc = ARG_COUNT(ht); - zval **argv[2]; - int i; - int resultIndex; - PHPFBResult* result; - int rowIndex ; - void** row; - FBSQLLS_FETCH(); - - resultIndex = FB_SQL_G(resultIndex); - - if ((argc < 0) || (argc > 1)) WRONG_PARAM_COUNT; - if (zend_get_parameters_ex(argc,&argv[0])==FAILURE) RETURN_FALSE; - - if (argc >= 1) { - convert_to_long_ex(argv[0]); - resultIndex = (*argv[0])->value.lval; - } - result = phpfbGetResult(resultIndex); - if (result == NULL) RETURN_FALSE; - - rowIndex = result->rowIndex; - - if (result->fetchHandle == NULL) { - RETURN_FALSE; - } - if (result->rowCount == 0) { - RETURN_FALSE; - } - if (result->rowCount == 0x7fffffff) { - if (!phpfbFetchRow(result,rowIndex)) { - RETURN_FALSE; - } - } - if (!(row = fbcrhRowAtIndex(result->rowHandler,rowIndex))) { - RETURN_FALSE; - } - if (array_init(return_value)==FAILURE) { - RETURN_FALSE; - } - result->row = row; - for (i=0; i < result->columnCount; i++) { - char* value; - unsigned int length; - if (row[i]) { - phpfbColumnAsString(result,i,row[i],&length,&value); - add_index_stringl(return_value,i,value,length,0); - } - else { - add_index_unset(return_value,i); - } - } - result->rowIndex = rowIndex+1; - result->columnIndex = 0; - FB_SQL_G(resultIndex) = resultIndex; + php_fbsql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, FBSQL_NUM); } /* }}} */ - -/* {{{ proto array fbsql_fetch_array(int result [, int result_typ]) - */ -PHP_FUNCTION(fbsql_fetch_array) +static void php_fbsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type) { int argc = ARG_COUNT(ht); zval **argv[2]; @@ -2611,7 +2573,6 @@ int resultIndex; PHPFBResult* result; int rowIndex; - int result_type = FBSQL_BOTH; void** row; FBSQLLS_FETCH(); @@ -2696,7 +2657,6 @@ result->rowIndex = result->rowIndex+1; result->columnIndex = 0; } -/* }}} */ /* {{{ proto int fbsql_data_seek(int result, int row_number)

« previous php.cvs (#5147) next »