VALUE fetchRowValue(int size, VALUE *parameters, VALUE self) { VALUE value = Qnil; if(size < 1) { rb_raise(rb_eArgError, "Wrong number of arguments (%d for %d)", size, 1); } /* Extract the parameters. */ value = getColumnValue(self, parameters[0]); if(value == Qnil) { if(size == 1 && rb_block_given_p()) { value = rb_yield(rb_ary_new()); } else { if(size == 1) { rb_raise(rb_eIndexError, "Column identifier '%s' not found in row.", STR2CSTR(parameters[0])); } value = parameters[1]; } } return(value); }
/** * This function provides the values_at method for the Row class. * * @param self A reference to the Row object to call the method on. * @param keys An array containing the name of the columns that should be * included in the output array. * * @return An array of the values that match the column names specified. * */ VALUE rowValuesAt(int size, VALUE *keys, VALUE self) { VALUE result = rb_ary_new(); int i; for(i = 0; i < size; i++) { rb_ary_push(result, getColumnValue(self, keys[i])); } return(result); }
attribs_map ResultSet::getTupleValues(void) { attribs_map tup_vals; if(current_tuple < 0 || current_tuple >= getTupleCount()) throw Exception(ERR_REF_TUPLE_INEXISTENT, __PRETTY_FUNCTION__, __FILE__, __LINE__); for(int col=0; col < getColumnCount(); col++) tup_vals[getColumnName(col)]=getColumnValue(col); return(tup_vals); }