>I were refered to this list...
>I found an old entry in the dev archive, explaining that I could achieve
>my goals, by "for each inner array you
>allocate a zval*, initialize it, add data to it, and add it to the
>return value."
>But how exactly do I add a zval?
>My guess is add_assoc_resource but where do the integer come from?
>Is it the returnvalue from array_init(allocatedZvalP)???
Just a snippet I created recently...
ZEND_FUNCTION(dbx_test)
{
zval **args[2];
zval *row[2];
int result;
for (result=0; result<2; ++result) {
args[result]=NULL;
}
if (ZEND_NUM_ARGS() !=2 || zend_get_parameters_array_ex(2, args) ==
FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(args[0]);
convert_to_string_ex(args[1]);
if (array_init(return_value) != SUCCESS) {
zend_error(E_ERROR, "Unable to create array for results...");
}
for (result=0; result<2; ++result) {
MAKE_STD_ZVAL(rowheader[result]);
if (array_init(rowheader[result]) != SUCCESS) {
zend_error(E_ERROR, "Unable to create array for rowheader
%d...", result);
}
}
for (result=0; result<2; ++result) {
MAKE_STD_ZVAL(row[result]);
if (array_init(row[result]) != SUCCESS) {
zend_error(E_ERROR, "Unable to create array for row %d...",
result);
}
}
add_index_string(row[0], 0, "bla00", 1);
add_index_string(row[0], 1, "bla10", 1);
add_index_string(row[1], 0, "bla01", 1);
add_index_string(row[1], 1, "bla11", 1);
zend_hash_index_update(return_value->value.ht, 0, (void *)&(row[0]),
sizeof(zval *), NULL);
zend_hash_index_update(return_value->value.ht, 1, (void *)&(row[1]),
sizeof(zval *), NULL);
}
Good luck!
Cheerio, Marc.
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]