/* fetch_row() */ static VALUE fetch_row(VALUE obj) { MYSQL_RES* res; unsigned int n; MYSQL_ROW row; unsigned long* lengths; VALUE ary; unsigned int i; check_free(obj); res = GetMysqlRes(obj); n = mysql_num_fields(res); row = mysql_fetch_row(res); lengths = mysql_fetch_lengths(res); if (row == NULL) return Qnil; ary = rb_ary_new2(n); for (i=0; i<n; i++) rb_ary_store(ary, i, row[i]? rb_tainted_str_new(row[i], lengths[i]): Qnil); return ary; }