示例#1
0
static VALUE cQuery_get(VALUE vself){
  int i, num, ksiz;
  const char *name, *col;
  VALUE vqry, vary, vcols;
  RDBQRY *qry;
  TCLIST *res;
  TCMAP *cols;
  vqry = rb_iv_get(vself, RDBQRYVNDATA);
  Data_Get_Struct(vqry, RDBQRY, qry);

  res = tcrdbqrysearchget(qry);
  num = tclistnum(res);
  vary = rb_ary_new2(num);
  for(i = 0; i < num; i++){
    vcols = rb_hash_new();
    cols = tcrdbqryrescols(res, i);
    if(cols){
      tcmapiterinit(cols);
      while((name = tcmapiternext(cols, &ksiz)) != NULL){
        col = tcmapget2(cols, name);
        if (ksiz == 0) name = "__id";
        rb_hash_aset(vcols, ID2SYM(rb_intern(name)), rb_str_new2(col));
      }
    }
    tcmapdel(cols);
    rb_ary_push(vary, vcols);
  }
  tclistdel(res);
  return vary;
}
示例#2
0
void*
xtcrdb_qryrescols(void* res, int index)
{
        return tcrdbqryrescols(res, index);
}