- zval **zparam = p;
- unsigned j, *i = va_arg(argv, unsigned *);
- smart_str *s = va_arg(argv, smart_str *);
- zval **zconv = va_arg(argv, zval **);
+ zval *return_value = NULL;
+ smart_str str = {0};
+
+ switch (type) {
+#if PHP_PQ_HAVE_PHP_JSON_H && defined(PHP_PQ_OID_JSON)
+# ifdef PHP_PQ_OID_JSONB
+ case PHP_PQ_OID_JSONB:
+# endif
+ case PHP_PQ_OID_JSON:
+ php_json_encode(&str, zobj, PHP_JSON_UNESCAPED_UNICODE TSRMLS_CC);
+ smart_str_0(&str);
+ break;
+#endif
+
+ case PHP_PQ_OID_DATE:
+ php_pqdt_to_string(zobj, "Y-m-d", &str.c, &str.len TSRMLS_CC);
+ break;
+
+ case PHP_PQ_OID_ABSTIME:
+ php_pqdt_to_string(zobj, "Y-m-d H:i:s", &str.c, &str.len TSRMLS_CC);
+ break;
+
+ case PHP_PQ_OID_TIMESTAMP:
+ php_pqdt_to_string(zobj, "Y-m-d H:i:s.u", &str.c, &str.len TSRMLS_CC);
+ break;
+
+ case PHP_PQ_OID_TIMESTAMPTZ:
+ php_pqdt_to_string(zobj, "Y-m-d H:i:s.uO", &str.c, &str.len TSRMLS_CC);
+ break;
+
+ default:
+ MAKE_STD_ZVAL(return_value);
+ MAKE_COPY_ZVAL(&zobj, return_value);
+ convert_to_string(return_value);
+ break;
+ }
+
+ if (str.c) {
+ MAKE_STD_ZVAL(return_value);
+ RETVAL_STRINGL(str.c, str.len, 0);
+ }
+
+ return return_value;
+}
+
+struct apply_to_param_from_array_arg {
+ php_pq_params_t *params;
+ unsigned index;
+ smart_str *buffer;
+ Oid type;
+ char delim;
+ zval **zconv;
+};
+
+static int apply_to_param_from_array(void *ptr, void *arg_ptr TSRMLS_DC)
+{
+ struct apply_to_param_from_array_arg subarg, *arg = arg_ptr;
+ zval *ztmp, **zparam = ptr, *zcopy = *zparam;