From 9ba862160ca65ed9a1e5eada87dcceba7fbf08d7 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Wed, 17 Sep 2014 14:13:53 +0200 Subject: [PATCH] more internal conversions --- src/php_pq_misc.c | 38 +++++++++- src/php_pq_misc.h | 1 + src/php_pq_params.c | 170 +++++++++++++++++++++++++++++++------------ src/php_pqconn.c | 2 +- src/php_pqres.c | 15 +++- src/php_pqres.h | 15 ++-- tests/async003.phpt | 4 +- tests/async004.phpt | 2 +- tests/async005.phpt | 2 +- tests/async006.phpt | 8 +- tests/cancel001.phpt | 2 +- tests/conv001.phpt | 150 ++++++++++++++++++++++++++++++++++++-- tests/res001.phpt | 4 +- tests/trans002.phpt | 4 +- 14 files changed, 342 insertions(+), 75 deletions(-) diff --git a/src/php_pq_misc.c b/src/php_pq_misc.c index ebbfa3a..9ca158e 100644 --- a/src/php_pq_misc.c +++ b/src/php_pq_misc.c @@ -72,11 +72,13 @@ ZEND_BEGIN_ARG_INFO_EX(ai_pqdt_to_string, 0, 0, 0) ZEND_END_ARG_INFO(); static PHP_METHOD(pqdt, __toString) { - zval *rv; + zval *rv = NULL; zend_call_method_with_1_params(&getThis(), php_pqdt_class_entry, NULL, "format", &rv, zend_read_property(php_pqdt_class_entry, getThis(), ZEND_STRL("format"), 0 TSRMLS_CC)); - RETVAL_ZVAL(rv, 1, 1); + if (rv) { + RETVAL_ZVAL(rv, 1, 1); + } } static zend_function_entry php_pqdt_methods[] = { @@ -105,6 +107,36 @@ zval *php_pqdt_from_string(char *dt_str, size_t dt_len, char *fmt, zval *zv TSRM return zv; } +void php_pqdt_to_string(zval *zdt, const char *format, char **str_buf, size_t *str_len TSRMLS_DC) +{ + zval rv; + + INIT_PZVAL(&rv); + ZVAL_NULL(&rv); + + if (Z_OBJ_HT_P(zdt)->cast_object + && SUCCESS == Z_OBJ_HT_P(zdt)->cast_object(zdt, &rv, IS_STRING TSRMLS_CC) + ) { + *str_len = Z_STRLEN(rv); + *str_buf = Z_STRVAL(rv); + } else if (instanceof_function(Z_OBJCE_P(zdt), php_date_get_date_ce() TSRMLS_CC)) { + zval *rv = NULL, *zfmt; + + MAKE_STD_ZVAL(zfmt); + ZVAL_STRING(zfmt, format, 1); + zend_call_method_with_1_params(&zdt, Z_OBJCE_P(zdt), NULL, "format", &rv, zfmt); + zval_ptr_dtor(&zfmt); + + if (rv) { + if (Z_TYPE_P(rv) == IS_STRING) { + *str_len = Z_STRLEN_P(rv); + *str_buf = estrndup(Z_STRVAL_P(rv), *str_len); + } + zval_ptr_dtor(&rv); + } + } +} + zend_class_entry *php_pqconv_class_entry; ZEND_BEGIN_ARG_INFO_EX(ai_pqconv_convert_types, 0, 0, 0) @@ -137,7 +169,7 @@ PHP_MINIT_FUNCTION(pq_misc) INIT_NS_CLASS_ENTRY(ce ,"pq", "DateTime", php_pqdt_methods); php_pqdt_class_entry = zend_register_internal_class_ex(&ce, php_date_get_date_ce(), "DateTime" TSRMLS_CC); - zend_declare_property_stringl(php_pqdt_class_entry, ZEND_STRL("format"), ZEND_STRL("Y-m-d H:i:s.u"), ZEND_ACC_PUBLIC TSRMLS_CC); + zend_declare_property_stringl(php_pqdt_class_entry, ZEND_STRL("format"), ZEND_STRL("Y-m-d H:i:s.uO"), ZEND_ACC_PUBLIC TSRMLS_CC); /* stop reading this file right here! */ if (SUCCESS == zend_hash_find(CG(class_table), ZEND_STRS("jsonserializable"), (void *) &json)) { diff --git a/src/php_pq_misc.h b/src/php_pq_misc.h index 196b35c..5bf8160 100644 --- a/src/php_pq_misc.h +++ b/src/php_pq_misc.h @@ -41,6 +41,7 @@ int compare_index(const void *lptr, const void *rptr TSRMLS_DC); zend_class_entry *php_pqdt_class_entry; zval *php_pqdt_from_string(char *datetime_str, size_t datetime_len, char *fmt, zval *zv TSRMLS_DC); +void php_pqdt_to_string(zval *zdt, const char *format, char **str_buf, size_t *str_len TSRMLS_DC); zend_class_entry *php_pqconv_class_entry; diff --git a/src/php_pq_params.c b/src/php_pq_params.c index 149da75..ffe5e70 100644 --- a/src/php_pq_params.c +++ b/src/php_pq_params.c @@ -17,6 +17,7 @@ #include #include #include +#include #include @@ -24,6 +25,7 @@ #include "php_pq.h" #include "php_pq_params.h" +#include "php_pq_misc.h" #undef PHP_PQ_TYPE #include "php_pq_type.h" @@ -77,12 +79,61 @@ unsigned php_pq_params_add_type_oid(php_pq_params_t *p, Oid type) return p->type.count; } -static int apply_to_param_from_array(void *p TSRMLS_DC, int argc, va_list argv, zend_hash_key *key) + +static zval *object_param_to_string(php_pq_params_t *p, zval *zobj, Oid type TSRMLS_DC) +{ + zval *return_value = NULL; + smart_str str = {0}; + + switch (type) { +#ifdef 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: + SEPARATE_ZVAL(&zobj); + convert_to_string(zobj); + return_value = zobj; + break; + } + + if (str.c) { + MAKE_STD_ZVAL(return_value); + RETVAL_STRINGL(str.c, str.len, 0); + } + + return return_value; +} + +static int apply_to_param_from_array(void *ptr TSRMLS_DC, int argc, va_list argv, zend_hash_key *key) { - zval **zparam = p; + php_pq_params_t *p = va_arg(argv, php_pq_params_t *); unsigned j, *i = va_arg(argv, unsigned *); smart_str *s = va_arg(argv, smart_str *); - zval **zconv = va_arg(argv, zval **); + Oid type = va_arg(argv, Oid); + zval *ztmp, **zparam = ptr, *zcopy = *zparam, **zconv = va_arg(argv, zval **); char *tmp; size_t len; int tmp_len; @@ -94,26 +145,26 @@ static int apply_to_param_from_array(void *p TSRMLS_DC, int argc, va_list argv, if (zconv) { zval *rv = NULL; - zend_call_method_with_1_params(zconv, NULL, NULL, "converttostring", &rv, *zparam); + zend_call_method_with_1_params(zconv, NULL, NULL, "converttostring", &rv, zcopy); convert_to_string(rv); - smart_str_appendl(s, Z_STRVAL_P(rv), Z_STRLEN_P(rv)); - zval_ptr_dtor(&rv); + zcopy = rv; + goto append_string; } else { - switch (Z_TYPE_PP(zparam)) { + switch (Z_TYPE_P(zcopy)) { case IS_NULL: smart_str_appends(s, "NULL"); break; case IS_BOOL: - smart_str_appends(s, Z_BVAL_PP(zparam) ? "t" : "f"); + smart_str_appends(s, Z_BVAL_P(zcopy) ? "t" : "f"); break; case IS_LONG: - smart_str_append_long(s, Z_LVAL_PP(zparam)); + smart_str_append_long(s, Z_LVAL_P(zcopy)); break; case IS_DOUBLE: - len = spprintf(&tmp, 0, "%F", Z_DVAL_PP(zparam)); + len = spprintf(&tmp, 0, "%F", Z_DVAL_P(zcopy)); smart_str_appendl(s, tmp, len); efree(tmp); break; @@ -121,23 +172,27 @@ static int apply_to_param_from_array(void *p TSRMLS_DC, int argc, va_list argv, case IS_ARRAY: j = 0; smart_str_appendc(s, '{'); - zend_hash_apply_with_arguments(Z_ARRVAL_PP(zparam) TSRMLS_CC, apply_to_param_from_array, 2, &j, s, zconv); + zend_hash_apply_with_arguments(Z_ARRVAL_P(zcopy) TSRMLS_CC, apply_to_param_from_array, 5, p, &j, s, type, zconv); smart_str_appendc(s, '}'); break; - default: - SEPARATE_ZVAL(zparam); - if (Z_TYPE_PP(zparam) != IS_STRING) { - convert_to_string(*zparam); + case IS_OBJECT: + if ((ztmp = object_param_to_string(p, zcopy, type TSRMLS_CC))) { + zcopy = ztmp; } + /* no break */ + default: + SEPARATE_ZVAL(&zcopy); + convert_to_string(zcopy); - tmp = php_addslashes(Z_STRVAL_PP(zparam), Z_STRLEN_PP(zparam), &tmp_len, 0 TSRMLS_CC); + append_string: + tmp = php_addslashes(Z_STRVAL_P(zcopy), Z_STRLEN_P(zcopy), &tmp_len, 0 TSRMLS_CC); smart_str_appendc(s, '"'); smart_str_appendl(s, tmp, tmp_len); smart_str_appendc(s, '"'); - if (*zparam != *((zval **) p)) { - zval_ptr_dtor(zparam); + if (zcopy != *zparam) { + zval_ptr_dtor(&zcopy); } efree(tmp); break; @@ -147,21 +202,46 @@ static int apply_to_param_from_array(void *p TSRMLS_DC, int argc, va_list argv, return ZEND_HASH_APPLY_KEEP; } -static void array_param_to_string(zval **zconv, HashTable *ht, char **str, int *len TSRMLS_DC) +static zval *array_param_to_string(php_pq_params_t *p, zval *zarr, Oid type TSRMLS_DC) { + zval *return_value, **zconv = NULL; smart_str s = {0}; unsigned i = 0; - smart_str_appendc(&s, '{'); - zend_hash_apply_with_arguments(ht TSRMLS_CC, apply_to_param_from_array, 3, &i, &s, zconv); - smart_str_appendc(&s, '}'); + switch (type) { +#ifdef PHP_PQ_OID_JSON +# ifdef PHP_PQ_OID_JSONB + case PHP_PQ_OID_JSONB: +# endif + case PHP_PQ_OID_JSON: + php_json_encode(&s, zarr, PHP_JSON_UNESCAPED_UNICODE TSRMLS_CC); + smart_str_0(&s); + break; +#endif + + default: + zend_hash_index_find(&p->type.conv, PHP_PQ_TYPE_OF_ARRAY(type), (void *) &zconv); + + smart_str_appendc(&s, '{'); + zend_hash_apply_with_arguments(Z_ARRVAL_P(zarr) TSRMLS_CC, apply_to_param_from_array, 5, p, &i, &s, (Oid) PHP_PQ_TYPE_OF_ARRAY(type), zconv); + smart_str_appendc(&s, '}'); + smart_str_0(&s); + break; + } + + /* must not return NULL */ + MAKE_STD_ZVAL(return_value); - smart_str_0(&s); - *str = s.c; - *len = s.len; + if (s.c) { + RETVAL_STRINGL(s.c, s.len, 0); + } else { + RETVAL_EMPTY_STRING(); + } + + return return_value; } -static void php_pq_params_set_param(php_pq_params_t *p, unsigned index, zval **zp) +static void php_pq_params_set_param(php_pq_params_t *p, unsigned index, zval **zpp) { zval **zconv = NULL; Oid type = p->type.count > index ? p->type.oids[index] : 0; @@ -170,48 +250,48 @@ static void php_pq_params_set_param(php_pq_params_t *p, unsigned index, zval **z if (type && SUCCESS == zend_hash_index_find(&p->type.conv, type, (void *) &zconv)) { zval *rv = NULL; - zend_call_method_with_1_params(zconv, NULL, NULL, "converttostring", &rv, *zp); + zend_call_method_with_1_params(zconv, NULL, NULL, "converttostring", &rv, *zpp); 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); } else { - zval **zpp = zp; + zval *tmp, *zcopy = *zpp; - switch (Z_TYPE_PP(zp)) { + switch (Z_TYPE_P(zcopy)) { case IS_NULL: p->param.strings[index] = NULL; return; case IS_BOOL: - p->param.strings[index] = Z_BVAL_PP(zp) ? "t" : "f"; + p->param.strings[index] = Z_BVAL_P(zcopy) ? "t" : "f"; return; case IS_DOUBLE: - SEPARATE_ZVAL(zp); - Z_TYPE_PP(zp) = IS_STRING; - Z_STRLEN_PP(zp) = spprintf(&Z_STRVAL_PP(zp), 0, "%F", Z_DVAL_PP(zpp)); + SEPARATE_ZVAL(&zcopy); + Z_TYPE_P(zcopy) = IS_STRING; + Z_STRLEN_P(zcopy) = spprintf(&Z_STRVAL_P(zcopy), 0, "%F", Z_DVAL_PP(zpp)); break; case IS_ARRAY: - { - zval *tmp; - MAKE_STD_ZVAL(tmp); - Z_TYPE_P(tmp) = IS_STRING; - zend_hash_index_find(&p->type.conv, PHP_PQ_TYPE_OF_ARRAY(type), (void *) &zconv); - array_param_to_string(zconv, Z_ARRVAL_PP(zp), &Z_STRVAL_P(tmp), &Z_STRLEN_P(tmp) TSRMLS_CC); - zp = &tmp; + zcopy = array_param_to_string(p, zcopy, type TSRMLS_CC); break; - } + + case IS_OBJECT: + if ((tmp = object_param_to_string(p, zcopy, type TSRMLS_CC))) { + zcopy = tmp; + break; + } + /* no break */ default: - convert_to_string_ex(zp); + convert_to_string_ex(&zcopy); break; } - p->param.strings[index] = Z_STRVAL_PP(zp); + p->param.strings[index] = Z_STRVAL_P(zcopy); - if (*zp != *zpp) { - zend_hash_next_index_insert(&p->param.dtor, zp, sizeof(zval *), NULL); + if (zcopy != *zpp) { + zend_hash_next_index_insert(&p->param.dtor, (void *) &zcopy, sizeof(zval *), NULL); } } } diff --git a/src/php_pqconn.c b/src/php_pqconn.c index c4d6c80..e869d92 100644 --- a/src/php_pqconn.c +++ b/src/php_pqconn.c @@ -458,7 +458,7 @@ static void php_pqconn_object_write_def_auto_conv(zval*object, void *o, zval *va } } - obj->intern->default_auto_convert = Z_LVAL_P(zac) & 0xff; + obj->intern->default_auto_convert = Z_LVAL_P(zac) & PHP_PQRES_CONV_ALL; if (zac != value) { zval_ptr_dtor(&zac); diff --git a/src/php_pqres.c b/src/php_pqres.c index eeda258..88a2268 100644 --- a/src/php_pqres.c +++ b/src/php_pqres.c @@ -17,6 +17,7 @@ #include #include +#include #include #include "php_pq.h" @@ -167,6 +168,18 @@ zval *php_pqres_typed_zval(php_pqres_t *res, char *val, size_t len, Oid typ TSRM php_pqdt_from_string(val, len, "Y-m-d H:i:s.uO", zv TSRMLS_CC); break; +#ifdef PHP_PQ_OID_JSON +# ifdef PHP_PQ_OID_JSONB + case PHP_PQ_OID_JSONB: +# endif + case PHP_PQ_OID_JSON: + if (!(res->auto_convert & PHP_PQRES_CONV_JSON)) { + goto noconversion; + } + php_json_decode_ex(zv, val, len, 0, 512 /* PHP_JSON_DEFAULT_DEPTH */ TSRMLS_CC); + break; +#endif + default: if (!(res->auto_convert & PHP_PQRES_CONV_ARRAY)) { goto noconversion; @@ -1153,7 +1166,7 @@ PHP_MINIT_FUNCTION(pqres) zend_hash_add(&php_pqres_object_prophandlers, "fetchType", sizeof("fetchType"), (void *) &ph, sizeof(ph), NULL); ph.write = NULL; - zend_declare_property_long(php_pqres_class_entry, ZEND_STRL("autoConvert"), PHP_PQRES_FETCH_ARRAY, ZEND_ACC_PUBLIC TSRMLS_CC); + zend_declare_property_long(php_pqres_class_entry, ZEND_STRL("autoConvert"), PHP_PQRES_CONV_ALL, ZEND_ACC_PUBLIC TSRMLS_CC); ph.read = php_pqres_object_read_auto_conv; ph.write = php_pqres_object_write_auto_conv; zend_hash_add(&php_pqres_object_prophandlers, "autoConvert", sizeof("autoConvert"), (void *) &ph, sizeof(ph), NULL); diff --git a/src/php_pqres.h b/src/php_pqres.h index 4afff39..d2d35d4 100644 --- a/src/php_pqres.h +++ b/src/php_pqres.h @@ -22,13 +22,14 @@ typedef enum php_pqres_fetch { PHP_PQRES_FETCH_OBJECT } php_pqres_fetch_t; -#define PHP_PQRES_CONV_BOOL 0x01 -#define PHP_PQRES_CONV_INT 0x02 -#define PHP_PQRES_CONV_FLOAT 0x04 -#define PHP_PQRES_CONV_SCALAR 0x0f -#define PHP_PQRES_CONV_ARRAY 0x10 -#define PHP_PQRES_CONV_DATETIME 0x20 -#define PHP_PQRES_CONV_ALL 0xff +#define PHP_PQRES_CONV_BOOL 0x0001 +#define PHP_PQRES_CONV_INT 0x0002 +#define PHP_PQRES_CONV_FLOAT 0x0004 +#define PHP_PQRES_CONV_SCALAR 0x000f +#define PHP_PQRES_CONV_ARRAY 0x0010 +#define PHP_PQRES_CONV_DATETIME 0x0020 +#define PHP_PQRES_CONV_JSON 0x0100 +#define PHP_PQRES_CONV_ALL 0xffff typedef struct php_pqres_iterator { zend_object_iterator zi; diff --git a/tests/async003.phpt b/tests/async003.phpt index e94b963..32d9dfd 100644 --- a/tests/async003.phpt +++ b/tests/async003.phpt @@ -42,7 +42,7 @@ object(pq\Result)#%d (8) { ["fetchType"]=> int(0) ["autoConvert"]=> - int(255) + int(65535) } object(pq\Result)#%d (8) { ["status"]=> @@ -60,6 +60,6 @@ object(pq\Result)#%d (8) { ["fetchType"]=> int(0) ["autoConvert"]=> - int(255) + int(65535) } DONE diff --git a/tests/async004.phpt b/tests/async004.phpt index d3db3f7..6fc2743 100644 --- a/tests/async004.phpt +++ b/tests/async004.phpt @@ -43,6 +43,6 @@ object(pq\Result)#%d (8) { ["fetchType"]=> int(0) ["autoConvert"]=> - int(255) + int(65535) } DONE diff --git a/tests/async005.phpt b/tests/async005.phpt index a956026..102ba13 100644 --- a/tests/async005.phpt +++ b/tests/async005.phpt @@ -52,6 +52,6 @@ object(pq\Result)#%d (8) { ["fetchType"]=> int(0) ["autoConvert"]=> - int(255) + int(65535) } DONE diff --git a/tests/async006.phpt b/tests/async006.phpt index 178d78c..4bcd889 100644 --- a/tests/async006.phpt +++ b/tests/async006.phpt @@ -43,7 +43,7 @@ object(pq\Result)#%d (8) { ["fetchType"]=> int(0) ["autoConvert"]=> - int(255) + int(65535) } object(pq\Result)#%d (8) { ["status"]=> @@ -61,7 +61,7 @@ object(pq\Result)#%d (8) { ["fetchType"]=> int(0) ["autoConvert"]=> - int(255) + int(65535) } object(pq\Result)#%d (8) { ["status"]=> @@ -79,7 +79,7 @@ object(pq\Result)#%d (8) { ["fetchType"]=> int(0) ["autoConvert"]=> - int(255) + int(65535) } object(pq\Result)#%d (8) { ["status"]=> @@ -97,6 +97,6 @@ object(pq\Result)#%d (8) { ["fetchType"]=> int(0) ["autoConvert"]=> - int(255) + int(65535) } DONE diff --git a/tests/cancel001.phpt b/tests/cancel001.phpt index f763847..5ccdf43 100644 --- a/tests/cancel001.phpt +++ b/tests/cancel001.phpt @@ -40,7 +40,7 @@ object(pq\Result)#%d (8) { ["fetchType"]=> int(0) ["autoConvert"]=> - int(255) + int(65535) } ERROR: canceling statement due to user request DONE diff --git a/tests/conv001.phpt b/tests/conv001.phpt index 7340c49..f8eef52 100644 --- a/tests/conv001.phpt +++ b/tests/conv001.phpt @@ -4,6 +4,8 @@ converter +--INI-- +date.timezone=UTC --FILE-- data = $data; + } + function __toString() { + return (string) $this->data; + } +} + $c = new pq\Connection(PQ_DSN); $c->exec("CREATE EXTENSION IF NOT EXISTS hstore"); $t = new pq\Types($c); $c->setConverter(new HStoreConverter($t)); $c->setConverter(new IntVectorConverter($t)); -$c->setConverter(new JSONConverter($t)); - -$r = $c->execParams("SELECT \$1 as hs, \$2 as iv, \$3 as oids, \$4 as js, \$5 as ia, \$6 as ta, \$7 as ba, \$8 as da", +if (!defined("pq\\Types::JSON")) { + $c->setConverter(new JSONConverter($t)); +} +$r = $c->execParams("SELECT \$1 as hs, \$2 as iv, \$3 as oids, \$4 as js, \$5 as ia, \$6 as ta, \$7 as ba, \$8 as da, \$9 as dbl, \$10 as bln, ". + "\$11 as dt1, \$12 as dt2, \$13 as dt3, \$14 as dt4, \$15 as dt5, \$16 as dt6, \$17 as dt7, \$18 as dt8, \$19 as txta ", array( // hstore array( @@ -112,7 +126,21 @@ $r = $c->execParams("SELECT \$1 as hs, \$2 as iv, \$3 as oids, \$4 as js, \$5 as array(array(array(1,2,3))), array(array("a\"","b}",null)), array(true,false), - array(1.1,2.2) + array(1.1,2.2), + // double + 123.456, + // bool + true, + // datetimes + new pq\Datetime, + new pq\Datetime, + new pq\Datetime, + new pq\Datetime, + new pq\Datetime, + new pq\Datetime, + new pq\Datetime, + new pq\Datetime, + [new Text(0), new Text(" or "), new Text(true)], ), array( $t["hstore"]->oid, @@ -122,7 +150,18 @@ $r = $c->execParams("SELECT \$1 as hs, \$2 as iv, \$3 as oids, \$4 as js, \$5 as $t["_int4"]->oid, $t["_text"]->oid, $t["_bool"]->oid, - $t["_float8"]->oid + $t["_float8"]->oid, + $t["float4"]->oid, + $t["bool"]->oid, + $t["date"]->oid, + $t["abstime"]->oid, + $t["timestamp"]->oid, + $t["timestamptz"]->oid, + $t["date"]->oid, + $t["abstime"]->oid, + $t["timestamp"]->oid, + $t["timestamptz"]->oid, + $t["_text"]->oid ) ); @@ -225,6 +264,107 @@ array(1) { [1]=> float(2.2) } + [8]=> + float(123.456) + [9]=> + bool(true) + [10]=> + object(pq\DateTime)#%d (4) { + ["format"]=> + string(5) "Y-m-d" + ["date"]=> + string(26) "%d-%d-%d 00:00:00.000000" + ["timezone_type"]=> + int(3) + ["timezone"]=> + string(3) "UTC" + } + [11]=> + object(pq\DateTime)#%d (4) { + ["format"]=> + string(11) "Y-m-d H:i:s" + ["date"]=> + string(26) "%d-%d-%d %d:%d:%d.000000" + ["timezone_type"]=> + int(1) + ["timezone"]=> + string(%d) "%s" + } + [12]=> + object(pq\DateTime)#%d (4) { + ["format"]=> + string(13) "Y-m-d H:i:s.u" + ["date"]=> + string(26) "%d-%d-%d %d:%d:%d.000000" + ["timezone_type"]=> + int(3) + ["timezone"]=> + string(3) "UTC" + } + [13]=> + object(pq\DateTime)#%d (4) { + ["format"]=> + string(14) "Y-m-d H:i:s.uO" + ["date"]=> + string(26) "%d-%d-%d %d:%d:%d.000000" + ["timezone_type"]=> + int(1) + ["timezone"]=> + string(%d) "%s" + } + [14]=> + object(pq\DateTime)#%d (4) { + ["format"]=> + string(5) "Y-m-d" + ["date"]=> + string(26) "%d-%d-%d 00:00:00.000000" + ["timezone_type"]=> + int(3) + ["timezone"]=> + string(3) "UTC" + } + [15]=> + object(pq\DateTime)#%d (4) { + ["format"]=> + string(11) "Y-m-d H:i:s" + ["date"]=> + string(26) "%d-%d-%d %d:%d:%d.000000" + ["timezone_type"]=> + int(1) + ["timezone"]=> + string(%d) "%s" + } + [16]=> + object(pq\DateTime)#%d (4) { + ["format"]=> + string(13) "Y-m-d H:i:s.u" + ["date"]=> + string(26) "%d-%d-%d %d:%d:%d.000000" + ["timezone_type"]=> + int(3) + ["timezone"]=> + string(3) "UTC" + } + [17]=> + object(pq\DateTime)#159 (4) { + ["format"]=> + string(14) "Y-m-d H:i:s.uO" + ["date"]=> + string(26) "%d-%d-%d %d:%d:%d.000000" + ["timezone_type"]=> + int(1) + ["timezone"]=> + string(%d) "%s" + } + [18]=> + array(3) { + [0]=> + string(1) "0" + [1]=> + string(4) " or " + [2]=> + string(1) "1" + } } } Done diff --git a/tests/res001.phpt b/tests/res001.phpt index 836a3bd..d42524a 100644 --- a/tests/res001.phpt +++ b/tests/res001.phpt @@ -74,7 +74,7 @@ object(pq\Result)#%d (8) { ["fetchType"]=> int(0) ["autoConvert"]=> - int(0) + int(65535) } array(9) { ["dummy"]=> @@ -94,6 +94,6 @@ array(9) { ["fetchType"]=> int(0) ["autoConvert"]=> - int(0) + int(65535) } Done diff --git a/tests/trans002.phpt b/tests/trans002.phpt index 49c71d8..8c901d4 100644 --- a/tests/trans002.phpt +++ b/tests/trans002.phpt @@ -68,7 +68,7 @@ object(pq\Connection)#%d (19) { ["defaultTransactionDeferrable"]=> bool(false) ["defaultAutoConvert"]=> - int(255) + int(65535) } int(0) bool(false) @@ -112,7 +112,7 @@ object(pq\Connection)#%d (19) { ["defaultTransactionDeferrable"]=> bool(false) ["defaultAutoConvert"]=> - int(255) + int(65535) } int(2) bool(true) -- 2.30.2