2bfbf22005-04-10Martin Nilsson 
6b43202005-04-10Martin Nilsson #pike __REAL_VERSION__
346aa42017-11-22Stephen R. van den Berg inherit __builtin.Sql.Result;
2bfbf22005-04-10Martin Nilsson 
346aa42017-11-22Stephen R. van den Berg array _values;
2bfbf22005-04-10Martin Nilsson  void create(array res) { if(!res || !arrayp(res))
6b43202005-04-10Martin Nilsson  error("Bad argument.\n");
346aa42017-11-22Stephen R. van den Berg  _values = res;
2bfbf22005-04-10Martin Nilsson } int num_rows() {
346aa42017-11-22Stephen R. van den Berg  return sizeof(_values);
2bfbf22005-04-10Martin Nilsson } int num_fields() {
346aa42017-11-22Stephen R. van den Berg  return sizeof(_values[0]);
2bfbf22005-04-10Martin Nilsson } int eof() {
346aa42017-11-22Stephen R. van den Berg  return index >= sizeof(_values);
2bfbf22005-04-10Martin Nilsson }
6b43202005-04-10Martin Nilsson // Only supports the name field.
2bfbf22005-04-10Martin Nilsson array(mapping(string:mixed)) fetch_fields() {
346aa42017-11-22Stephen R. van den Berg  array(mapping(string:mixed)) res = allocate(sizeof(_values[0]));
2bfbf22005-04-10Martin Nilsson  int i;
346aa42017-11-22Stephen R. van den Berg  foreach(sort(indices(_values[0])), string name)
2bfbf22005-04-10Martin Nilsson  res[i++] = ([ "name": name ]); return res; } void seek(int skip) {
6b43202005-04-10Martin Nilsson  if(skip<0) error("Skip argument not positive.\n");
2bfbf22005-04-10Martin Nilsson  index += skip; } int|array(string|int) fetch_row() { array res;
3524712015-05-26Martin Nilsson 
346aa42017-11-22Stephen R. van den Berg  if (index >= sizeof(_values))
2bfbf22005-04-10Martin Nilsson  return 0;
346aa42017-11-22Stephen R. van den Berg  sort(indices(_values[index]), res = values(_values[index]));
2bfbf22005-04-10Martin Nilsson  index++; return res; }
9261a02016-04-02Henrik Grubbström (Grubba)  this_program next_result() { return 0; }