return &php_pqtypes_create_object_ex(class_type, NULL)->zo;
}
-static void php_pqtypes_object_read_connection(zval *object, void *o, zval *return_value)
+static void php_pqtypes_object_read_connection(void *o, zval *return_value)
{
php_pqtypes_object_t *obj = o;
php_pq_object_to_zval(obj->intern->conn, return_value);
}
-static void php_pqtypes_object_gc_connection(zval *object, void *o, zval *return_value)
+static void php_pqtypes_object_gc_connection(void *o, zval *return_value)
{
php_pqtypes_object_t *obj = o;
zval zconn;
add_next_index_zval(return_value, &zconn);
}
-static int has_dimension(HashTable *ht, zval *member, zend_string **key, zend_long *index)
+static inline int has_dimension(HashTable *ht, zval *member, zend_string **key, zend_long *index)
{
if (Z_TYPE_P(member) == IS_LONG) {
*index = Z_LVAL_P(member);
}
}
-static int php_pqtypes_object_has_dimension(zval *object, zval *member, int check_empty)
+static inline int php_pqtypes_object_has_dimension_ex(zend_object *object, zval *member, int check_empty)
{
- php_pqtypes_object_t *obj = PHP_PQ_OBJ(object, NULL);
+ php_pqtypes_object_t *obj = PHP_PQ_OBJ(NULL, object);
zend_string *key = NULL;
zend_long index = 0;
return 0;
}
+#if PHP_VERSION_ID >= 80000
+static int php_pqtypes_object_has_dimension(zend_object *object, zval *member, int check_empty)
+{
+ return php_pqtypes_object_has_dimension_ex(object, member, check_empty);
+}
+#else
+static int php_pqtypes_object_has_dimension(zval *object, zval *member, int check_empty)
+{
+ return php_pqtypes_object_has_dimension_ex(Z_OBJ_P(object), member, check_empty);
+}
+#endif
-static zval *php_pqtypes_object_read_dimension(zval *object, zval *member, int type, zval *rv)
+static inline zval *php_pqtypes_object_read_dimension_ex(zend_object *object, zval *member, int type, zval *rv)
{
- php_pqtypes_object_t *obj = PHP_PQ_OBJ(object, NULL);
+ php_pqtypes_object_t *obj = PHP_PQ_OBJ(NULL, object);
zend_string *key = NULL;
zend_long index = 0;
zval *data = NULL;
return data;
}
+#if PHP_VERSION_ID >= 80000
+static zval *php_pqtypes_object_read_dimension(zend_object *object, zval *member, int type, zval *rv)
+{
+ return php_pqtypes_object_read_dimension_ex(object, member, type, rv);
+}
+#else
+static zval *php_pqtypes_object_read_dimension(zval *object, zval *member, int type, zval *rv)
+{
+ return php_pqtypes_object_read_dimension_ex(Z_OBJ_P(object), member, type, rv);
+}
+#endif
+
+#if PHP_VERSION_ID >= 80000
+static void php_pqtypes_object_write_dimension(zend_object *object, zval *offset, zval *value)
+{
+ throw_exce(EX_RUNTIME, "pq\\Types object must not be modified");
+}
+#else
+static void php_pqtypes_object_write_dimension(zval *object, zval *offset, zval *value)
+{
+ throw_exce(EX_RUNTIME, "pq\\Types object must not be modified");
+}
+#endif
+
+#if PHP_VERSION_ID >= 80000
+static void php_pqtypes_object_unset_dimension(zend_object *object, zval *offset)
+{
+ throw_exce(EX_RUNTIME, "pq\\Types object must not be modified");
+}
+#else
+static void php_pqtypes_object_unset_dimension(zval *object, zval *offset)
+{
+ throw_exce(EX_RUNTIME, "pq\\Types object must not be modified");
+}
+#endif
ZEND_BEGIN_ARG_INFO_EX(ai_pqtypes_construct, 0, 0, 1)
ZEND_ARG_OBJ_INFO(0, connection, pq\\Connection, 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", NULL, znsp);
+ php_pq_call_method(getThis(), "refresh", 1, NULL, znsp);
} else {
- zend_call_method_with_0_params(getThis(), Z_OBJCE_P(getThis()), NULL, "refresh", NULL);
+ php_pq_call_method(getThis(), "refresh", 0, NULL);
}
}
}
}
#define PHP_PQ_TYPES_QUERY \
- "select t.oid, t.* " \
+ "select t.oid, t.typname, t.* " \
"from pg_type t join pg_namespace n on t.typnamespace=n.oid " \
- "where typisdefined " \
- "and typrelid=0"
+ "where typisdefined"
#ifndef PHP_PQ_OID_TEXT
# define PHP_PQ_OID_TEXT 25
#endif
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);
smart_str_appends(&str, PHP_PQ_TYPES_QUERY " and nspname in(");
- zend_hash_apply_with_arguments(nsp TSRMLS_CC, apply_nsp, 2, params, &str);
+ zend_hash_apply_with_arguments(nsp, apply_nsp, 2, params, &str);
smart_str_appendc(&str, ')');
smart_str_0(&str);
- res = PQexecParams(obj->intern->conn->intern->conn, smart_str_v(&str), 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, smart_str_v(&str), params->param.count, params->type.oids, (const char *const*) params->param.strings, NULL, NULL, 0);
smart_str_free(&str);
php_pq_params_free(¶ms);
}
}
- PHP_PQclear(res);
+ php_pqres_clear(res);
php_pqconn_notify_listeners(obj->intern->conn);
}
}
}
static zend_function_entry php_pqtypes_methods[] = {
- PHP_ME(pqtypes, __construct, ai_pqtypes_construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
+ PHP_ME(pqtypes, __construct, ai_pqtypes_construct, ZEND_ACC_PUBLIC)
PHP_ME(pqtypes, refresh, ai_pqtypes_refresh, ZEND_ACC_PUBLIC)
{0}
};
php_pqtypes_class_entry->create_object = php_pqtypes_create_object;
/*
- zend_class_implements(php_pqtypes_class_entry TSRMLS_CC, 1, zend_ce_arrayaccess);
+ zend_class_implements(php_pqtypes_class_entry, 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;
php_pqtypes_object_handlers.clone_obj = NULL;
- php_pqtypes_object_handlers.get_property_ptr_ptr = NULL;
+ php_pqtypes_object_handlers.get_property_ptr_ptr = php_pq_object_get_prop_ptr_null;
php_pqtypes_object_handlers.get_gc = php_pq_object_get_gc;
php_pqtypes_object_handlers.get_properties = php_pq_object_properties;
php_pqtypes_object_handlers.get_debug_info = php_pq_object_debug_info;
php_pqtypes_object_handlers.has_dimension = php_pqtypes_object_has_dimension;
php_pqtypes_object_handlers.read_dimension = php_pqtypes_object_read_dimension;
- php_pqtypes_object_handlers.unset_dimension = NULL;
- php_pqtypes_object_handlers.write_dimension = NULL;
+ php_pqtypes_object_handlers.unset_dimension = php_pqtypes_object_unset_dimension;
+ php_pqtypes_object_handlers.write_dimension = php_pqtypes_object_write_dimension;
zend_hash_init(&php_pqtypes_object_prophandlers, 1, NULL, php_pq_object_prophandler_dtor, 1);