+ PGresult *res;
+
+ if (nsp && zend_hash_num_elements(nsp)) {
+ int i, count;
+ Oid *oids;
+ char **params = NULL;
+ HashTable zdtor;
+ smart_str str = {0};
+
+ smart_str_appends(&str, PHP_PQ_TYPES_QUERY " and nspname in(");
+ zend_hash_init(&zdtor, 0, NULL, ZVAL_PTR_DTOR, 0);
+ count = php_pq_params_to_array(nsp, ¶ms, &zdtor TSRMLS_CC);
+ oids = ecalloc(count + 1, sizeof(*oids));
+ for (i = 0; i < count; ++i) {
+ oids[i] = PHP_PQ_OID_TEXT;
+ if (i) {
+ smart_str_appendc(&str, ',');
+ }
+ smart_str_appendc(&str, '$');
+ smart_str_append_unsigned(&str, i+1);
+ }
+ smart_str_appendc(&str, ')');
+ smart_str_0(&str);
+
+ res = PQexecParams(obj->intern->conn->intern->conn, str.c, count, oids, (const char *const*) params, NULL, NULL, 0);
+
+ smart_str_free(&str);
+ efree(oids);
+ efree(params);
+ zend_hash_destroy(&zdtor);
+ } else {
+ res = PQexec(obj->intern->conn->intern->conn, PHP_PQ_TYPES_QUERY " and nspname in ('public', 'pg_catalog')");
+ }