iter = ecalloc(1, sizeof(*iter));
iter->zi.funcs = &php_pqres_iterator_funcs;
iter->zi.data = object;
- Z_ADDREF_P(object);
+ /* do not addref, because the iterator lives inside this object anyway */
zfetch_type = prop = zend_read_property(ce, object, ZEND_STRL("fetchType"), 0 TSRMLS_CC);
if (Z_TYPE_P(zfetch_type) != IS_LONG) {
zval_ptr_dtor(&iter->current_val);
iter->current_val = NULL;
}
- zval_ptr_dtor((zval **) &iter->zi.data);
efree(iter);
}
zend_hash_init(&r->bound, 0, 0, ZVAL_PTR_DTOR, 0);
zend_hash_init(&r->converters, 0, 0, ZVAL_PTR_DTOR, 0);
zend_hash_copy(&r->converters, &conn_obj->intern->converters, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
- php_pqres_create_object_ex(php_pqres_class_entry, r, &obj TSRMLS_CC);
+ r->default_fetch_type = conn_obj->intern->default_fetch_type;
+
+ php_pqres_create_object_ex(php_pqres_class_entry, r, &obj TSRMLS_CC);
PQresultSetInstanceData(res, php_pqconn_event, obj);
if (ptr) {
if (obj->intern->iter) {
RETVAL_LONG(obj->intern->iter->fetch_type);
} else {
- RETVAL_LONG(PHP_PQRES_FETCH_ARRAY);
+ RETVAL_LONG(obj->intern->default_fetch_type);
}
}
zval **row = NULL;
if (fetch_type == -1) {
- fetch_type = obj->intern->iter ? obj->intern->iter->fetch_type : PHP_PQRES_FETCH_ARRAY;
+ fetch_type = obj->intern->iter ? obj->intern->iter->fetch_type : obj->intern->default_fetch_type;
}
zend_replace_error_handling(EH_THROW, exce(EX_RUNTIME), &zeh TSRMLS_CC);
}
if (fetch_type == -1) {
- fetch_type = obj->intern->iter ? obj->intern->iter->fetch_type : PHP_PQRES_FETCH_ARRAY;
+ fetch_type = obj->intern->iter ? obj->intern->iter->fetch_type : obj->intern->default_fetch_type;
}
if (keys) {
int r, rows = PQntuples(obj->intern->res);
if (fetch_type == -1) {
- fetch_type = obj->intern->iter ? obj->intern->iter->fetch_type : PHP_PQRES_FETCH_ARRAY;
+ fetch_type = obj->intern->iter ? obj->intern->iter->fetch_type : obj->intern->default_fetch_type;
}
array_init(return_value);