Fabian Groffen a écrit :
I'm looking for equivalents of fname and fnumber methods in MAPI. Couldn't find an equivalent. So, is there a way, when you get the result of a query, to get the names of the fields in the result?
Did you check mapi_get_field_count and mapi_get_table, mapi_get_name, mapi_get_type and mapi_get_len?
Ok, I admit they are actually not documented at all, not even in the code.
Yes. I discovered them late last night by looking at the php bindings. Page 225 of m5manual.pdf. For instance proto string monetdb_field_name proto string monetdb_field_table proto string monetdb_field_type and had a look in the monetdb-client-1.34.2/src/php/Cimpl/php_monetdb.c file: Line 1449:
/* {{{ proto string monetdb_field_name(resource result, int field_number) Returns the name of the field */ PHP_FUNCTION(monetdb_field_name) { php_monetdb_get_field_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_MONETDB_FIELD_NAME); } /* }}} */
and line 1402:
/* {{{ php_monetdb_get_field_info */ static void php_monetdb_get_field_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type) {
[...]
switch (entry_type) { case PHP_MONETDB_FIELD_NAME: Z_STRVAL_P(return_value) = mapi_get_name(monetdb_result, Z_LVAL_PP(field)); Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value)); Z_STRVAL_P(return_value) = estrndup(Z_STRVAL_P(return_value),Z_STRLEN_P(return_value)); Z_TYPE_P(return_value) = IS_STRING; break; case PHP_MONETDB_FIELD_TABLE: Z_STRVAL_P(return_value) = mapi_get_table(monetdb_result, Z_LVAL_PP(field)); Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value)); Z_STRVAL_P(return_value) = estrndup(Z_STRVAL_P(return_value),Z_STRLEN_P(return_value)); Z_TYPE_P(return_value) = IS_STRING; break; case PHP_MONETDB_FIELD_TYPE: Z_STRVAL_P(return_value) = mapi_get_type(monetdb_result, Z_LVAL_PP(field)); Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value)); Z_STRVAL_P(return_value) = estrndup(Z_STRVAL_P(return_value),Z_STRLEN_P(return_value)); Z_TYPE_P(return_value) = IS_STRING; break; default: RETURN_FALSE; } } /* }}} */
So you can indeed find the mapi_get_name/table/type functions, but they are only documented through the PHP interface, not the regular Mapi documentation. Fixing that would be great, I guess. -- Guillaume Yziquel http://yziquel.homelinux.org/