}
}
+#if HAVE_PQCONNINFO
+static void php_pqconn_object_read_params(zval *object, void *o, zval *return_value TSRMLS_DC)
+{
+ php_pqconn_object_t *obj = o;
+ PQconninfoOption *ptr, *params = PQconninfo(obj->intern->conn);
+
+ array_init(return_value);
+
+ if (params) {
+ for (ptr = params; ptr->keyword; ++ptr) {
+ if (ptr->val) {
+ add_assoc_string(return_value, ptr->keyword, ptr->val, 1);
+ } else {
+ add_assoc_null(return_value, ptr->keyword);
+ }
+ }
+ PQconninfoFree(params);
+ }
+}
+#endif
+
static void php_pqconn_object_read_options(zval *object, void *o, zval *return_value TSRMLS_DC)
{
php_pqconn_object_t *obj = o;
static int apply_unlisten(void *p TSRMLS_DC, int argc, va_list argv, zend_hash_key *key)
{
php_pqconn_object_t *obj = va_arg(argv, php_pqconn_object_t *);
- PGresult *res = unlisten(obj->intern->conn, key->arKey, key->nKeyLength - 1);
+ PGresult *res = unlisten(obj->intern->conn, key->arKey, key->nKeyLength - 1 TSRMLS_CC);
if (res) {
PHP_PQclear(res);
if (!obj->intern) {
throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\Connection not initialized");
} else if (SUCCESS == zend_hash_del(&obj->intern->listeners, channel_str, channel_len + 1)) {
- PGresult *res = unlisten(obj->intern->conn, channel_str, channel_len);
+ PGresult *res = unlisten(obj->intern->conn, channel_str, channel_len TSRMLS_CC);
if (res) {
php_pqres_success(res TSRMLS_CC);
}
}
-static inline char *declare_str(const char *name_str, size_t name_len, unsigned flags, const char *query_str, size_t query_len)
-{
- size_t decl_len = name_len + query_len + sizeof("DECLARE BINARY INSENSITIVE NO SCROLL CURSOR WITHOUT HOLD FOR ");
- char *decl_str;
-
- decl_str = emalloc(decl_len);
- decl_len = slprintf(decl_str, decl_len, "DECLARE %s %s %s %s CURSOR %s FOR %s",
- name_str,
- (flags & PHP_PQ_DECLARE_BINARY) ? "BINARY" : "",
- (flags & PHP_PQ_DECLARE_INSENSITIVE) ? "INSENSITIVE" : "",
- (flags & PHP_PQ_DECLARE_NO_SCROLL) ? "NO SCROLL" :
- (flags & PHP_PQ_DECLARE_SCROLL) ? "SCROLL" : "",
- (flags & PHP_PQ_DECLARE_WITH_HOLD) ? "WITH HOLD" : "",
- query_str
- );
- return decl_str;
-}
-
STATUS php_pqconn_declare(zval *object, php_pqconn_object_t *obj, const char *decl TSRMLS_DC)
{
PGresult *res;
if (!obj->intern) {
throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\Connection not initialized");
} else {
- char *decl = declare_str(name_str, name_len, flags, query_str, query_len);
+ char *decl = php_pqcur_declare_str(name_str, name_len, flags, query_str, query_len);
if (SUCCESS != php_pqconn_declare(getThis(), obj, decl TSRMLS_CC)) {
efree(decl);
if (!obj->intern) {
throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\Connection not initialized");
} else {
- char *decl = declare_str(name_str, name_len, flags, query_str, query_len);
+ char *decl = php_pqcur_declare_str(name_str, name_len, flags, query_str, query_len);
if (SUCCESS != php_pqconn_declare_async(getThis(), obj, decl TSRMLS_CC)) {
efree(decl);
php_pqconn_object_handlers.get_properties = php_pq_object_properties;
php_pqconn_object_handlers.get_debug_info = php_pq_object_debug_info;
- zend_hash_init(&php_pqconn_object_prophandlers, 19, NULL, NULL, 1);
+ zend_hash_init(&php_pqconn_object_prophandlers, 20, NULL, NULL, 1);
zend_declare_property_long(php_pqconn_class_entry, ZEND_STRL("status"), CONNECTION_BAD, ZEND_ACC_PUBLIC TSRMLS_CC);
ph.read = php_pqconn_object_read_status;
ph.read = php_pqconn_object_read_port;
zend_hash_add(&php_pqconn_object_prophandlers, "port", sizeof("port"), (void *) &ph, sizeof(ph), NULL);
+#if HAVE_PQCONNINFO
+ zend_declare_property_null(php_pqconn_class_entry, ZEND_STRL("params"), ZEND_ACC_PUBLIC TSRMLS_CC);
+ ph.read = php_pqconn_object_read_params;
+ zend_hash_add(&php_pqconn_object_prophandlers, "params", sizeof("params"), (void *) &ph, sizeof(ph), NULL);
+#endif
+
zend_declare_property_null(php_pqconn_class_entry, ZEND_STRL("options"), ZEND_ACC_PUBLIC TSRMLS_CC);
ph.read = php_pqconn_object_read_options;
zend_hash_add(&php_pqconn_object_prophandlers, "options", sizeof("options"), (void *) &ph, sizeof(ph), NULL);