Skip to content

Conversation

devnexen
Copy link
Member

support associative and indexes arrays for results.

support associative and indexes arrays for results.
@devnexen devnexen marked this pull request as ready for review June 20, 2025 23:27
@devnexen devnexen requested a review from kocsismate as a code owner June 20, 2025 23:27
Comment on lines 2047 to 2066
zval result;
array_init_size(&result, result_obj->column_count);

for (i = 0; i < result_obj->column_count; i ++) {
zval data;
sqlite_value_to_zval(result_obj->stmt_obj->stmt, i, &data);

if (mode & PHP_SQLITE3_NUM) {
add_index_zval(&result, i, &data);
}

if (mode & PHP_SQLITE3_ASSOC) {
if (mode & PHP_SQLITE3_NUM) {
if (Z_REFCOUNTED(data)) {
Z_ADDREF(data);
}
}
zend_symtable_update(Z_ARR_P(&result), result_obj->column_names[i], &data);
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part of the code is almost identical to fetchArray() and is therefore redundant. How about consolidating it into an inline function or something similar?

@nielsdos
Copy link
Member

This was merged via 375316d wasn't it? Please confirm and close this PR if so.

@devnexen
Copy link
Member Author

indeed.

@devnexen devnexen closed this Jun 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants