当前位置: 首页>>代码示例>>C++>>正文


C++ zend_hash_index_update函数代码示例

本文整理汇总了C++中zend_hash_index_update函数的典型用法代码示例。如果您正苦于以下问题:C++ zend_hash_index_update函数的具体用法?C++ zend_hash_index_update怎么用?C++ zend_hash_index_update使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了zend_hash_index_update函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: spl_fixedarray_object_get_properties

static HashTable* spl_fixedarray_object_get_properties(zval *obj) /* {{{{ */
{
	spl_fixedarray_object *intern  = Z_SPLFIXEDARRAY_P(obj);
	HashTable *ht = zend_std_get_properties(obj);
	zend_long  i = 0;

	if (intern->array) {
		zend_long j = zend_hash_num_elements(ht);

		for (i = 0; i < intern->array->size; i++) {
			if (!Z_ISUNDEF(intern->array->elements[i])) {
				zend_hash_index_update(ht, i, &intern->array->elements[i]);
				if (Z_REFCOUNTED(intern->array->elements[i])){
					Z_ADDREF(intern->array->elements[i]);
				}
			} else {
				zend_hash_index_update(ht, i, &EG(uninitialized_zval));
			}
		}
		if (j > intern->array->size) {
			for (i = intern->array->size; i < j; ++i) {
				zend_hash_index_del(ht, i);
			}
		}
	}

	return ht;
}
开发者ID:20uf,项目名称:php-src,代码行数:28,代码来源:spl_fixedarray.c

示例2: zephir_array_update_zval

/**
 * @brief Updates value in @a arr at position @a index with @a value
 * @param[in,out] arr Array
 * @param index Index
 * @param[in,out] value Value
 * @param flags Flags
 * @return Whether the operation succeeded
 * @retval @c FAILURE Failure, @a arr is not an array or @a index is of not supported type
 * @retval @c SUCCESS Success
 * @note @c index will be handled as follows: @c NULL is treated as an empty string, @c double values are cast to @c integer, @c bool or @c resource are treated as @c integer
 * @throw @c E_WARNING if @a offset is not a scalar or @c arr is not an array
 *
 * Equivalent to <tt>$arr[$index] = $value</tt> in PHP.
 * Flags may be a bitwise OR of the following values:
 * @arg @c PH_CTOR: create a copy of @a value and work with that copy; @c *value will be updated with the newly constructed value
 * @arg @c PH_SEPARATE: separate @a arr if its reference count is greater than 1; @c *arr will contain the separated version
 * @arg @c PH_COPY: increment the reference count on @c **value
 */
int zephir_array_update_zval(zval **arr, zval *index, zval **value, int flags) {

    HashTable *ht;

    if (Z_TYPE_PP(arr) != IS_ARRAY) {
        zend_error(E_WARNING, "Cannot use a scalar value as an array (2)");
        return FAILURE;
    }

    if ((flags & PH_CTOR) == PH_CTOR) {
        zval *new_zv;
        Z_DELREF_PP(value);
        ALLOC_ZVAL(new_zv);
        INIT_PZVAL_COPY(new_zv, *value);
        *value = new_zv;
        zval_copy_ctor(new_zv);
    }

    if ((flags & PH_SEPARATE) == PH_SEPARATE) {
        SEPARATE_ZVAL_IF_NOT_REF(arr);
    }

    if ((flags & PH_COPY) == PH_COPY) {
        Z_ADDREF_PP(value);
    }

    ht = Z_ARRVAL_PP(arr);

    switch (Z_TYPE_P(index)) {
    case IS_NULL:
        return zend_symtable_update(ht, "", 1, value, sizeof(zval*), NULL);

    case IS_DOUBLE:
        return zend_hash_index_update(ht, (ulong)Z_DVAL_P(index), value, sizeof(zval*), NULL);

    case IS_LONG:
    case IS_BOOL:
    case IS_RESOURCE:
        return zend_hash_index_update(ht, Z_LVAL_P(index), value, sizeof(zval*), NULL);

    case IS_STRING:
        return zend_symtable_update(ht, Z_STRVAL_P(index), Z_STRLEN_P(index)+1, value, sizeof(zval*), NULL);

    default:
        zend_error(E_WARNING, "Illegal offset type");
        return FAILURE;
    }
}
开发者ID:golovanov,项目名称:php-ext-zendxml,代码行数:66,代码来源:array.c

示例3: process_nested_data

static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, long elements, int objprops)
{
	while (elements-- > 0) {
		zval *key, *data, **old_data;

		ALLOC_INIT_ZVAL(key);

		if (!php_var_unserialize2(&key, p, max, NULL TSRMLS_CC)) {
			zval_dtor(key);
			FREE_ZVAL(key);
			return 0;
		}

		if (Z_TYPE_P(key) != IS_LONG && Z_TYPE_P(key) != IS_STRING) {
			zval_dtor(key);
			FREE_ZVAL(key);
			return 0;
		}

		ALLOC_INIT_ZVAL(data);

		if (!php_var_unserialize2(&data, p, max, var_hash TSRMLS_CC)) {
			zval_dtor(key);
			FREE_ZVAL(key);
			zval_dtor(data);
			FREE_ZVAL(data);
			return 0;
		}

		switch (Z_TYPE_P(key)) {
		case IS_LONG:
            if (objprops) {
                /* show a warning for not compatible */
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "got integer prop. %d", Z_LVAL_P(key));
            }
			if (zend_hash_index_find(ht, Z_LVAL_P(key), (void **)&old_data)==SUCCESS) {
				var_push_dtor(var_hash, old_data);
			}
			zend_hash_index_update(ht, Z_LVAL_P(key), &data, sizeof(data), NULL);
			break;
		case IS_STRING:
			if (zend_symtable_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) {
				var_push_dtor(var_hash, old_data);
			}
			zend_symtable_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &data, sizeof(data), NULL);
			break;
		}
		
		
		zval_dtor(key);
		FREE_ZVAL(key);

		if (elements && *(*p-1) != ';' && *(*p-1) != '}') {
			(*p)--;
			return 0;
		}
	}

	return 1;
}
开发者ID:qiaolun,项目名称:unserialize,代码行数:60,代码来源:var_unserializer2.c

示例4: process_nested_data

static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, long elements, int objprops)
{
	while (elements-- > 0) {
		zval *key, *data, **old_data;

		ALLOC_INIT_ZVAL(key);

		if (!php_var_unserialize(&key, p, max, NULL TSRMLS_CC)) {
            var_push_dtor_no_addref(var_hash, &key);
			return 0;
		}

		if (Z_TYPE_P(key) != IS_LONG && Z_TYPE_P(key) != IS_STRING) {
            var_push_dtor_no_addref(var_hash, &key);
			return 0;
		}

		ALLOC_INIT_ZVAL(data);

		if (!php_var_unserialize(&data, p, max, var_hash TSRMLS_CC)) {
            var_push_dtor_no_addref(var_hash, &key);
            var_push_dtor_no_addref(var_hash, &data);
			return 0;
		}

		if (!objprops) {
			switch (Z_TYPE_P(key)) {
			case IS_LONG:
				if (zend_hash_index_find(ht, Z_LVAL_P(key), (void **)&old_data)==SUCCESS) {
					var_push_dtor(var_hash, old_data);
				}
				zend_hash_index_update(ht, Z_LVAL_P(key), &data, sizeof(data), NULL);
				break;
			case IS_STRING:
				if (zend_symtable_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) {
					var_push_dtor(var_hash, old_data);
				}
				zend_symtable_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &data, sizeof(data), NULL);
				break;
			}
		} else {
			/* object properties should include no integers */
			convert_to_string(key);
			if (zend_hash_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) {
				var_push_dtor(var_hash, old_data);
			}
			zend_hash_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &data,
					sizeof data, NULL);
		}
		var_push_dtor(var_hash, &data);
        var_push_dtor_no_addref(var_hash, &key);

		if (elements && *(*p-1) != ';' && *(*p-1) != '}') {
			(*p)--;
			return 0;
		}
	}

	return 1;
}
开发者ID:AzerTyQsdF,项目名称:osx,代码行数:60,代码来源:var_unserializer.c

示例5: phalcon_array_update_long

/**
 * Updates values on arrays by long indexes only
 */
int phalcon_array_update_long(zval **arr, ulong index, zval **value, int flags TSRMLS_DC){

	if (Z_TYPE_PP(arr) != IS_ARRAY) {
		php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Cannot use a scalar value as an array");
		return FAILURE;
	}

	if ((flags & PH_CTOR) == PH_CTOR) {
		zval *new_zv;
		Z_DELREF_PP(value);
		ALLOC_ZVAL(new_zv);
		INIT_PZVAL_COPY(new_zv, *value);
		*value = new_zv;
		zval_copy_ctor(new_zv);
	}

	if ((flags & PH_SEPARATE) == PH_SEPARATE) {
		if (Z_REFCOUNT_PP(arr) > 1) {
			zval *new_zv;
			Z_DELREF_PP(arr);
			ALLOC_ZVAL(new_zv);
			INIT_PZVAL_COPY(new_zv, *arr);
			*arr = new_zv;
			zval_copy_ctor(new_zv);
	    }
	}

	if ((flags & PH_COPY) == PH_COPY) {
		Z_ADDREF_PP(value);
	}

	return zend_hash_index_update(Z_ARRVAL_PP(arr), index, value, sizeof(zval *), NULL);
}
开发者ID:fatihzkaratana,项目名称:cphalcon,代码行数:36,代码来源:array.c

示例6: xc_coverager_clean

/* }}} */
static void xc_coverager_clean(TSRMLS_D) /* {{{ */
{
	if (XG(coverages)) {
		HashPosition pos;
		coverager_t *pcov;

		zend_hash_internal_pointer_reset_ex(XG(coverages), &pos);
		while (zend_hash_get_current_data_ex(XG(coverages), (void **) &pcov, &pos) == SUCCESS) {
			long *phits;
			coverager_t cov;
			HashPosition pos2;

			cov = *pcov;

			zend_hash_internal_pointer_reset_ex(cov, &pos2);
			while (zend_hash_get_current_data_ex(cov, (void**)&phits, &pos2) == SUCCESS) {
				long hits = *phits;

				if (hits != -1) {
					hits = -1;
					zend_hash_index_update(cov, pos2->h, &hits, sizeof(hits), NULL);
				}
				zend_hash_move_forward_ex(cov, &pos2);
			}

			zend_hash_move_forward_ex(XG(coverages), &pos);
		}
	}
}
开发者ID:alepharchives,项目名称:xcache,代码行数:30,代码来源:xc_coverager.c

示例7: php_autoglobal_merge

/* {{{ php_autoglobal_merge
 */
static void php_autoglobal_merge(HashTable *dest, HashTable *src)
{
	zval *src_entry, *dest_entry;
	zend_string *string_key;
	zend_ulong num_key;
	int globals_check = (dest == (&EG(symbol_table)));

	ZEND_HASH_FOREACH_KEY_VAL(src, num_key, string_key, src_entry) {
		if (Z_TYPE_P(src_entry) != IS_ARRAY
			|| (string_key && (dest_entry = zend_hash_find(dest, string_key)) == NULL)
			|| (string_key == NULL && (dest_entry = zend_hash_index_find(dest, num_key)) == NULL)
			|| Z_TYPE_P(dest_entry) != IS_ARRAY) {
			if (Z_REFCOUNTED_P(src_entry)) {
				Z_ADDREF_P(src_entry);
			}
			if (string_key) {
				if (!globals_check || string_key->len != sizeof("GLOBALS") - 1
						|| memcmp(string_key->val, "GLOBALS", sizeof("GLOBALS") - 1)) {
					zend_hash_update(dest, string_key, src_entry);
				} else if (Z_REFCOUNTED_P(src_entry)) {
					Z_DELREF_P(src_entry);
				}
			} else {
				zend_hash_index_update(dest, num_key, src_entry);
			}
		} else {
			SEPARATE_ZVAL(dest_entry);
			php_autoglobal_merge(Z_ARRVAL_P(dest_entry), Z_ARRVAL_P(src_entry));
		}
	} ZEND_HASH_FOREACH_END();
}
开发者ID:Crell,项目名称:php-src,代码行数:33,代码来源:php_variables.c

示例8: _php_import_environment_variables

void _php_import_environment_variables(zval *array_ptr)
{
	char **env, *p;
	size_t name_len, len;
	zval val;
	zend_ulong idx;

	for (env = environ; env != NULL && *env != NULL; env++) {
		p = strchr(*env, '=');
		if (!p
		 || p == *env
		 || !valid_environment_name(*env, p)) {
			/* malformed entry? */
			continue;
		}
		name_len = p - *env;
		p++;
		len = strlen(p);
		if (len == 0) {
			ZVAL_EMPTY_STRING(&val);
		} else if (len == 1) {
			ZVAL_INTERNED_STR(&val, ZSTR_CHAR((zend_uchar)*p));
		} else {
			ZVAL_NEW_STR(&val, zend_string_init(p, len, 0));
		}
		if (ZEND_HANDLE_NUMERIC_STR(*env, name_len, idx)) {
			zend_hash_index_update(Z_ARRVAL_P(array_ptr), idx, &val);
		} else {
			php_register_variable_quick(*env, name_len, &val, Z_ARRVAL_P(array_ptr));
		}
	}
}
开发者ID:IMSoP,项目名称:php-src,代码行数:32,代码来源:php_variables.c

示例9: orbit_save_data

/*
 * save a corba object to a php object
 */
void orbit_save_data(zval * php_object, int type, void * data)
{
    pval * orbit_data_handle = NULL;
    long id = zend_list_insert(
                  data, 										/* data */
                  type								/* type */
              );


    /*
     * do it like they do in php_COM_call_function_handler
     * (insert into some magic hash index)
     */
    ALLOC_ZVAL(orbit_data_handle);	/* allocate memory for value */

    orbit_data_handle->type = IS_LONG;
    orbit_data_handle->value.lval = id;

    pval_copy_constructor(orbit_data_handle);	/* why? */

    INIT_PZVAL(orbit_data_handle);	/* set reference count */

    zend_hash_index_update(
        php_object->value.obj.properties, /* hashtable */
        0, 																/* hash??? */
        &orbit_data_handle,								/* data */
        sizeof(pval *),										/* data size */
        NULL															/* destination */
    );
}
开发者ID:jehurodrig,项目名称:PHP-4.0.6-16-07-2009,代码行数:33,代码来源:class.c

示例10: zephir_array_update_long

/**
 * @brief Updates value in @a arr at position @a index with @a value
 * @param[in,out] arr Array
 * @param index Index
 * @param[in,out] value Value
 * @param flags Flags
 * @return Whether the operation succeeded
 * @retval @c FAILURE Failure, @a arr is not an array
 * @retval @c SUCCESS Success
 * @throw @c E_WARNING if @c arr is not an array
 *
 * Equivalent to <tt>$arr[$index] = $value</tt> in PHP where @c $index is an integer.
 * Flags may be a bitwise OR of the following values:
 * @arg @c PH_CTOR: create a copy of @a value and work with that copy; @c *value will be updated with the newly constructed value
 * @arg @c PH_SEPARATE: separate @a arr if its reference count is greater than 1; @c *arr will contain the separated version
 * @arg @c PH_COPY: increment the reference count on @c **value
 */
int zephir_array_update_long(zval **arr, unsigned long index, zval **value, int flags ZEPHIR_DEBUG_PARAMS) {

    if (Z_TYPE_PP(arr) != IS_ARRAY) {
        zend_error(E_WARNING, "Cannot use a scalar value as an array in %s on line %d", file, line);
        return FAILURE;
    }

    if ((flags & PH_CTOR) == PH_CTOR) {
        zval *new_zv;
        Z_DELREF_PP(value);
        ALLOC_ZVAL(new_zv);
        INIT_PZVAL_COPY(new_zv, *value);
        *value = new_zv;
        zval_copy_ctor(new_zv);
    }

    if ((flags & PH_SEPARATE) == PH_SEPARATE) {
        SEPARATE_ZVAL_IF_NOT_REF(arr);
    }

    if ((flags & PH_COPY) == PH_COPY) {
        Z_ADDREF_PP(value);
    }

    return zend_hash_index_update(Z_ARRVAL_PP(arr), index, value, sizeof(zval *), NULL);
}
开发者ID:golovanov,项目名称:php-ext-zendxml,代码行数:43,代码来源:array.c

示例11: full_user_list

static int full_user_list(struct user_info *uentp, struct fulluserlistarg* arg,int count)
{
    struct user_info userinfo=*uentp;
    struct userec *lookupuser;
    zval* element;
    if (!userinfo.active || !userinfo.pid) {
        return 0;
    }
    if (!HAS_PERM(getCurrentUser(), PERM_SEECLOAK) && userinfo.invisible && strcmp(userinfo.userid, getCurrentUser()->userid)) {
        /*Haohmaru.99.4.24.让隐身者能看见自己 */
        return 0;
    }
    if (count+1<arg->start)
        return COUNT;
    if (count+1-arg->start>=arg->num)
        return QUIT;
    MAKE_STD_ZVAL ( element );
    array_init ( element );

    add_assoc_bool ( element, "invisible", userinfo.invisible );
    add_assoc_long ( element, "pid", userinfo.pid );
    add_assoc_bool ( element, "isfriend", isfriend(userinfo.userid) );
    add_assoc_string ( element, "userid", userinfo.userid, 1 );
    add_assoc_string ( element, "username", userinfo.username, 1 );
    if( getuser(userinfo.userid, &lookupuser) == 0 ) lookupuser=NULL;
    add_assoc_string ( element, "userfrom", HAS_PERM(getCurrentUser(), PERM_SYSOP)? userinfo.from: SHOW_USERIP(lookupuser, userinfo.from), 1 );
    add_assoc_string ( element, "mode", ModeType(userinfo.mode), 1 );
    add_assoc_long ( element, "idle", (long)(time(0) - userinfo.freshtime)/60 );
    
    zend_hash_index_update(Z_ARRVAL_P(arg->return_value), count+1-arg->start, (void *) &element, sizeof(zval *), NULL);
    return COUNT;
}
开发者ID:marvelliu,项目名称:lilacsrc,代码行数:32,代码来源:phpbbs.session.c

示例12: switch

/* {{{ php_oci_lob_create()
 Create LOB descriptor and allocate all the resources needed */
php_oci_descriptor *php_oci_lob_create (php_oci_connection *connection, long type TSRMLS_DC)
{
	php_oci_descriptor *descriptor;

	switch (type) {
		case OCI_DTYPE_FILE:
		case OCI_DTYPE_LOB:
		case OCI_DTYPE_ROWID:
			/* these three are allowed */
			break;
		default:
			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown descriptor type %ld", type);
			return NULL;
			break;
	}

	descriptor = ecalloc(1, sizeof(php_oci_descriptor));
	descriptor->type = type;
	descriptor->connection = connection;
	zend_list_addref(descriptor->connection->rsrc_id);

	PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIDescriptorAlloc, (connection->env, (dvoid*)&(descriptor->descriptor), descriptor->type, (size_t) 0, (dvoid **) 0));

	if (OCI_G(errcode) != OCI_SUCCESS) {
		OCI_G(errcode) = php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC);
		PHP_OCI_HANDLE_ERROR(connection, OCI_G(errcode));
		efree(descriptor);
		return NULL;
	}

	PHP_OCI_REGISTER_RESOURCE(descriptor, le_descriptor);
	
	descriptor->lob_current_position = 0;
	descriptor->lob_size = -1;				/* we should set it to -1 to know, that it's just not initialized */
	descriptor->buffering = PHP_OCI_LOB_BUFFER_DISABLED;				/* buffering is off by default */
	descriptor->charset_form = SQLCS_IMPLICIT;	/* default value */
	descriptor->charset_id = connection->charset;
	descriptor->is_open = 0;

	if (descriptor->type == OCI_DTYPE_LOB || descriptor->type == OCI_DTYPE_FILE) {
		/* add Lobs & Files to hash. we'll flush them at the end */
		if (!connection->descriptors) {
			ALLOC_HASHTABLE(connection->descriptors);
			zend_hash_init(connection->descriptors, 0, NULL, php_oci_descriptor_flush_hash_dtor, 0);
			connection->descriptor_count = 0;
		}
		
		descriptor->index = (connection->descriptor_count)++;
		if (connection->descriptor_count == LONG_MAX) {
			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Internal descriptor counter has reached limit");
			php_oci_connection_descriptors_free(connection TSRMLS_CC);
			return NULL;
		}

		zend_hash_index_update(connection->descriptors,descriptor->index,&descriptor,sizeof(php_oci_descriptor *),NULL);
	}
	return descriptor;

} /* }}} */
开发者ID:NobleGaz,项目名称:PHP,代码行数:61,代码来源:oci8_lob.c

示例13: buession_hash_index_add_null

BUESSION_API int buession_hash_index_add_null(HashTable *ht, ulong index TSRMLS_DC){
	zval *value;

	MAKE_STD_ZVAL(value);
	ZVAL_NULL(value);

	return zend_hash_index_update(ht, index, (void *) &value, sizeof(zval *), NULL);
}
开发者ID:eduosi,项目名称:buession,代码行数:8,代码来源:hash.c

示例14: hash_to_zval

static int hash_to_zval(VALUE key, VALUE value, VALUE zval_array) {
    zval *v;
    zval *ary;

    if (key == Qundef) {
        return ST_CONTINUE;
    }

    ary = (zval *)zval_array;
    v = value_to_zval(value);

    if (key == Qtrue) {
        zend_hash_index_update(Z_ARRVAL_P(ary), 1, &v, sizeof(zval *), NULL);
        return ST_CONTINUE;
    }

    if (key == Qfalse || key == Qnil) {
        zend_hash_index_update(Z_ARRVAL_P(ary), 0, &v, sizeof(zval *), NULL);
        return ST_CONTINUE;
    }

    if (TYPE(key) == T_FIXNUM) {
        int idx = FIX2INT(key);
        zend_hash_index_update(Z_ARRVAL_P(ary), idx, &v, sizeof(zval *), NULL);
        return ST_CONTINUE;
    }

    switch (TYPE(key)) {
        case T_BIGNUM:
            key = rb_big2str(key, 10);
            break;
        case T_SYMBOL:
            key = rb_sym_to_s(key);
            break;
        case T_STRING:
            key = rb_string_value(&key);
            break;
        default:
            rb_raise(rb_eRuntimeError, "invalid key (%d)", TYPE(key));
    }

    //ZEND_HANDLE_NUMERIC(RSTRING_PTR(key), RSTRING_LEN(key), zend_hash_index_update(Z_ARRVAL_P(ary), idx, &v, sizeof(zval *), NULL));
    zend_symtable_update(Z_ARRVAL_P(ary), RSTRING_PTR(key), RSTRING_LEN(key) + 1, &v, sizeof(zval *), NULL);

    return ST_CONTINUE;
}
开发者ID:Epictetus,项目名称:php_embed,代码行数:46,代码来源:convert.c

示例15: dbx_odbc_getrow

int dbx_odbc_getrow(zval ** rv, zval ** result_handle, long row_number, INTERNAL_FUNCTION_PARAMETERS) {
    /*/ returns array[0..columncount-1] as strings on success or 0 as long on failure /*/
    int number_of_arguments;
    zval ** arguments[2];
    zval * num_fields_zval=NULL;
    zval * fetch_row_result_zval=NULL;
    zval * field_result_zval=NULL;
    zval * field_index_zval;
    zval * returned_zval=NULL;
    long field_index;
    long field_count=-1;

    /*/ get # fields /*/
    MAKE_STD_ZVAL(num_fields_zval);
    ZVAL_LONG(num_fields_zval, 0);
    if (!dbx_odbc_getcolumncount(&num_fields_zval, result_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU)) {
        return 0;
        }
    field_count=num_fields_zval->value.lval;
    FREE_ZVAL(num_fields_zval);
    /*/ fetch row /*/
    number_of_arguments=1;
    arguments[0]=result_handle;
    dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "odbc_fetch_row", &fetch_row_result_zval, number_of_arguments, arguments);
    if (!fetch_row_result_zval || fetch_row_result_zval->type!=IS_BOOL) {
        if (fetch_row_result_zval) zval_ptr_dtor(&fetch_row_result_zval);
        return 0;
        }
    if (fetch_row_result_zval->value.lval==0) {
        (*rv)->type=IS_LONG;
        (*rv)->value.lval=0; /*/ ok, no more rows /*/
        zval_ptr_dtor(&fetch_row_result_zval);
        return 0;
        }
    zval_ptr_dtor(&fetch_row_result_zval);
    /*/ fill array with field results... /*/
    MAKE_STD_ZVAL(returned_zval);
    if (array_init(returned_zval) != SUCCESS) {
        zend_error(E_ERROR, "dbx_odbc_getrow: unable to create result-array...");
        FREE_ZVAL(returned_zval);
        return 0;
        }
    MAKE_STD_ZVAL(field_index_zval);
    ZVAL_LONG(field_index_zval, 0);
    number_of_arguments=2;
    for (field_index=0; field_index<field_count; ++field_index) {
        ZVAL_LONG(field_index_zval, field_index+1);
        arguments[0]=result_handle;
        arguments[1]=&field_index_zval;
        dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "odbc_result", &field_result_zval, number_of_arguments, arguments);
        zend_hash_index_update(returned_zval->value.ht, field_index, (void *)&(field_result_zval), sizeof(zval *), NULL);
        }
    FREE_ZVAL(field_index_zval);

    MOVE_RETURNED_TO_RV(rv, returned_zval);
    return 1;
    }
开发者ID:jehurodrig,项目名称:PHP-4.0.6-16-07-2009,代码行数:57,代码来源:dbx_odbc.c


注:本文中的zend_hash_index_update函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。