ZEND_BEGIN_ARG_INFO_EX(ai_pqconv_convert_types, 0, 0, 0)
ZEND_END_ARG_INFO();
-ZEND_BEGIN_ARG_INFO_EX(ai_pqconv_convert_from_string, 0, 0, 1)
+ZEND_BEGIN_ARG_INFO_EX(ai_pqconv_convert_from_string, 0, 0, 2)
ZEND_ARG_INFO(0, data)
+ ZEND_ARG_INFO(0, type)
ZEND_END_ARG_INFO();
-ZEND_BEGIN_ARG_INFO_EX(ai_pqconv_convert_to_string, 0, 0, 1)
+ZEND_BEGIN_ARG_INFO_EX(ai_pqconv_convert_to_string, 0, 0, 2)
ZEND_ARG_INFO(0, data)
+ ZEND_ARG_INFO(0, type)
ZEND_END_ARG_INFO();
zend_function_entry php_pqconv_methods[] = {
}
if (arg->zconv) {
- zval *rv = NULL;
+ zval *ztype, *rv = NULL;
- zend_call_method_with_1_params(arg->zconv, NULL, NULL, "converttostring", &rv, zcopy);
+ MAKE_STD_ZVAL(ztype);
+ ZVAL_LONG(ztype, arg->type);
+ zend_call_method_with_2_params(arg->zconv, NULL, NULL, "converttostring", &rv, zcopy, ztype);
+ zval_ptr_dtor(&ztype);
convert_to_string(rv);
zcopy = rv;
goto append_string;
TSRMLS_DF(p);
if (type && SUCCESS == zend_hash_index_find(&p->type.conv, type, (void *) &zconv)) {
- zval *rv = NULL;
+ zval *ztype, *rv = NULL;
- zend_call_method_with_1_params(zconv, NULL, NULL, "converttostring", &rv, *zpp);
+ MAKE_STD_ZVAL(ztype);
+ ZVAL_LONG(ztype, type);
+ zend_call_method_with_2_params(zconv, NULL, NULL, "converttostring", &rv, *zpp, ztype);
+ zval_ptr_dtor(&ztype);
convert_to_string(rv);
p->param.strings[index] = Z_STRVAL_P(rv);
zend_hash_next_index_insert(&p->param.dtor, (void *) &rv, sizeof(zval *), NULL);
if (!obj->intern) {
throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\COPY not initialized");
} else if (obj->intern->direction != PHP_PQCOPY_FROM_STDIN) {
- throw_exce(EX_RUNTIME TSRMLS_CC, "pq\\COPY was not initialized with FROM_STDIN");
+ throw_exce(EX_BAD_METHODCALL TSRMLS_CC, "pq\\COPY was not initialized with FROM_STDIN");
} else {
if (1 != PQputCopyData(obj->intern->conn->intern->conn, data_str, data_len)) {
throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to put COPY data (%s)", PHP_PQerrorMessage(obj->intern->conn->intern->conn));
php_pqcopy_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
if (!obj->intern) {
- throw_exce(EX_RUNTIME TSRMLS_CC, "pq\\COPY not intitialized");
+ throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\COPY not intitialized");
} else if (obj->intern->direction != PHP_PQCOPY_FROM_STDIN) {
- throw_exce(EX_RUNTIME TSRMLS_CC, "pq\\COPY was not intitialized with FROM_STDIN");
+ throw_exce(EX_BAD_METHODCALL TSRMLS_CC, "pq\\COPY was not intitialized with FROM_STDIN");
} else {
if (1 != PQputCopyEnd(obj->intern->conn->intern->conn, error_str)) {
throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to end COPY (%s)", PHP_PQerrorMessage(obj->intern->conn->intern->conn));
MAKE_STD_ZVAL(zv);
if (SUCCESS == zend_hash_index_find(&res->converters, typ, (void *) &zconv)) {
- zval *tmp = NULL;
+ zval *ztype, *tmp = NULL;
+ MAKE_STD_ZVAL(ztype);
+ ZVAL_LONG(ztype, typ);
ZVAL_STRINGL(zv, val, len, 1);
- zend_call_method_with_1_params(zconv, NULL, NULL, "convertfromstring", &tmp, zv);
+ zend_call_method_with_2_params(zconv, NULL, NULL, "convertfromstring", &tmp, zv, ztype);
+ zval_ptr_dtor(&ztype);
if (tmp) {
zval_ptr_dtor(&zv);
return [ $this->types["hstore"]->oid ];
}
- function convertFromString($string) {
+ function convertFromString($string, $type) {
return eval("return [$string];");
}
- function convertToString($data) {
+ function convertToString($data, $type) {
$string = "";
foreach ($data as $k => $v) {
if (isset($v)) {
];
}
- function convertFromString($string) {
+ function convertFromString($string, $type) {
return array_map("intval", explode(" ", $string));
}
- function convertToString($data) {
+ function convertToString($data, $type) {
return implode(" ", $data);
}
}
return [ $this->types["json"]->oid ];
}
- function convertFromString($string) {
+ function convertFromString($string, $type) {
return json_decode($string);
}
- function convertToString($data) {
+ function convertToString($data, $type) {
return json_encode($data);
}
}