Skip to content
Snippets Groups Projects
Select Git revision
  • faa3c7ad140c53ec72eb5788d3904c1e03191d34
  • master default protected
  • 9.0
  • marcus/wix3
  • 8.0
  • nt-tools
  • 7.8
  • 7.6
  • 7.4
  • 7.2
  • 7.0
  • 0.6
  • rosuav/latex-markdown-renderer
  • rxnpatch/rxnpatch
  • marcus/gobject-introspection
  • rxnpatch/8.0
  • rosuav/pre-listening-ports
  • rosuav/async-annotations
  • rosuav/pgsql-ssl
  • rxnpatch/rxnpatch-broken/2023-10-06T094250
  • grubba/fdlib
  • v8.0.2020
  • v8.0.2018
  • v8.0.2016
  • v8.0.2014
  • v8.0.2012
  • v8.0.2008
  • v8.0.2006
  • v8.0.2004
  • v8.0.2002
  • v8.0.2000
  • v8.0.1998
  • v8.0.1996
  • v8.0.1994
  • v8.0.1992
  • v8.0.1990
  • v8.0.1988
  • v8.0.1986
  • rxnpatch/clusters/8.0/2025-04-29T124414
  • rxnpatch/2025-04-29T124414
  • v8.0.1984
41 results

sql_array_result.pike

Blame
  • user avatar
    Martin Nilsson authored
    Rev: lib/modules/Sql.pmod/sql_array_result.pike:1.2
    Rev: lib/modules/Sql.pmod/sql_object_result.pike:1.2
    Rev: lib/modules/Sql.pmod/sql_result.pike:1.14
    6b43206f
    History
    sql_array_result.pike 889 B
    
    #pike __REAL_VERSION__
    
    inherit .sql_result;
    
    array master_res;
    
    void create(array res) {
      if(!res || !arrayp(res))
        error("Bad argument.\n");
      master_res = res;
    }
    
    int num_rows() {
      return sizeof(master_res);
    }
    
    int num_fields() {
      return sizeof(master_res[0]);
    }
    
    int eof() {
      return index >= sizeof(master_res);
    }
    
    // Only supports the name field.
    array(mapping(string:mixed)) fetch_fields() {
      array(mapping(string:mixed)) res = allocate(sizeof(master_res[0]));
      int i;
    
      foreach(sort(indices(master_res[0])), string name)
        res[i++] = ([ "name": name ]);
    
      return res;
    }
    
    void seek(int skip) {
      if(skip<0) error("Skip argument not positive.\n");
      index += skip;
    }
    
    int|array(string|int) fetch_row() {
      array res;
          
      if (index >= sizeof(master_res))
        return 0;
    
      sort(indices(master_res[index]), res = values(master_res[index]));
      index++;
      return res;
    }