X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=src%2Fphp_pqtypes.c;h=25cdc1e7a546fefe5c133e31a0831e85865700fb;hb=df586b558795570822225a3a458bd91a1f7ab433;hp=e5733da650d748a76a0b39336ea85ab2eda78f0a;hpb=a04c77181328660f1ca748cb82a20abe43cebb65;p=m6w6%2Fext-pq diff --git a/src/php_pqtypes.c b/src/php_pqtypes.c index e5733da..25cdc1e 100644 --- a/src/php_pqtypes.c +++ b/src/php_pqtypes.c @@ -189,7 +189,7 @@ ZEND_END_ARG_INFO(); static PHP_METHOD(pqtypes, __construct) { zend_error_handling zeh; zval *zconn, *znsp = NULL; - STATUS rv; + ZEND_RESULT_CODE rv; zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC); rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|a!", &zconn, php_pqconn_class_entry, &znsp); @@ -207,7 +207,7 @@ static PHP_METHOD(pqtypes, __construct) { obj->intern = ecalloc(1, sizeof(*obj->intern)); obj->intern->conn = conn_obj; php_pq_object_addref(conn_obj TSRMLS_CC); - zend_hash_init(&obj->intern->types, 300, NULL, ZVAL_PTR_DTOR, 0); + zend_hash_init(&obj->intern->types, 512, NULL, ZVAL_PTR_DTOR, 0); if (znsp) { zend_call_method_with_1_params(&getThis(), Z_OBJCE_P(getThis()), NULL, "refresh", &retval, znsp); @@ -260,7 +260,7 @@ ZEND_END_ARG_INFO(); static PHP_METHOD(pqtypes, refresh) { HashTable *nsp = NULL; zend_error_handling zeh; - STATUS rv; + ZEND_RESULT_CODE rv; zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC); rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|H/!", &nsp); @@ -275,7 +275,7 @@ static PHP_METHOD(pqtypes, refresh) { PGresult *res; if (!nsp || !zend_hash_num_elements(nsp)) { - res = PQexec(obj->intern->conn->intern->conn, PHP_PQ_TYPES_QUERY " and nspname in ('public', 'pg_catalog')"); + res = php_pq_exec(obj->intern->conn->intern->conn, PHP_PQ_TYPES_QUERY " and nspname in ('public', 'pg_catalog')"); } else { smart_str str = {0}; php_pq_params_t *params = php_pq_params_init(&obj->intern->conn->intern->converters, NULL, NULL TSRMLS_CC); @@ -285,7 +285,7 @@ static PHP_METHOD(pqtypes, refresh) { smart_str_appendc(&str, ')'); smart_str_0(&str); - res = PQexecParams(obj->intern->conn->intern->conn, str.c, params->param.count, params->type.oids, (const char *const*) params->param.strings, NULL, NULL, 0); + res = php_pq_exec_params(obj->intern->conn->intern->conn, str.c, params->param.count, params->type.oids, (const char *const*) params->param.strings, NULL, NULL, 0); smart_str_free(&str); php_pq_params_free(¶ms); @@ -309,7 +309,7 @@ static PHP_METHOD(pqtypes, refresh) { } } - PHP_PQclear(res); + php_pqres_clear(res); php_pqconn_notify_listeners(obj->intern->conn TSRMLS_CC); } } @@ -337,6 +337,10 @@ PHP_MINIT_FUNCTION(pqtypes) php_pqtypes_class_entry = zend_register_internal_class_ex(&ce, NULL, NULL TSRMLS_CC); php_pqtypes_class_entry->create_object = php_pqtypes_create_object; + /* + zend_class_implements(php_pqtypes_class_entry TSRMLS_CC, 1, zend_ce_arrayaccess); + */ + memcpy(&php_pqtypes_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); php_pqtypes_object_handlers.read_property = php_pq_object_read_prop; php_pqtypes_object_handlers.write_property = php_pq_object_write_prop; @@ -356,14 +360,9 @@ PHP_MINIT_FUNCTION(pqtypes) ph.read = php_pqtypes_object_read_connection; zend_hash_add(&php_pqtypes_object_prophandlers, "connection", sizeof("connection"), (void *) &ph, sizeof(ph), NULL); -#ifdef HAVE_PHP_PQ_TYPE_H # undef PHP_PQ_TYPE # define PHP_PQ_TYPE(name, oid) zend_declare_class_constant_long(php_pqtypes_class_entry, ZEND_STRL(name), oid TSRMLS_CC); # include "php_pq_type.h" - zend_declare_class_constant_bool(php_pqtypes_class_entry, ZEND_STRL("DEFINED"), 1 TSRMLS_CC); -#else - zend_declare_class_constant_bool(php_pqtypes_class_entry, ZEND_STRL("DEFINED"), 0 TSRMLS_CC); -#endif return SUCCESS; }