+static zval **column_at(zval *row, int col TSRMLS_DC)
+{
+ zval **data = NULL;
+ HashTable *ht = HASH_OF(row);
+ int count = zend_hash_num_elements(ht);
+
+ if (col < count) {
+ zend_hash_internal_pointer_reset(ht);
+ while (col-- > 0) {
+ zend_hash_move_forward(ht);
+ }
+ zend_hash_get_current_data(ht, (void *) &data);
+ } else {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Column index %d does excess column count %d", col, count);
+ }
+ return data;
+}
+
+ZEND_BEGIN_ARG_INFO_EX(ai_pqres_fetch_col, 0, 0, 0)
+ ZEND_ARG_INFO(0, col_num)
+ZEND_END_ARG_INFO();
+static PHP_METHOD(pqres, fetchCol) {
+ zend_error_handling zeh;
+ long fetch_col = 0;
+
+ zend_replace_error_handling(EH_THROW, NULL, &zeh TSRMLS_CC);
+ if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &fetch_col)) {
+ php_pqres_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+ zval **row = php_pqres_iteration(getThis(), obj, obj->iter ? obj->iter->fetch_type : 0 TSRMLS_CC);
+
+ if (row) {
+ zval **col = column_at(*row, fetch_col TSRMLS_CC);
+
+ if (col) {
+ RETVAL_ZVAL(*col, 1, 0);
+ } else {
+ RETVAL_FALSE;
+ }
+ } else {
+ RETVAL_FALSE;
+ }
+ }
+ zend_restore_error_handling(&zeh TSRMLS_CC);
+
+}
+