Skip to content

Commit

Permalink
res_obj_to_array() now also adds <table>.<column> entries to the resu…
Browse files Browse the repository at this point in the history
…lt array.

I'm not sure if this is a good idea though, since it renders it impossible to
determine how many columns there are in the result from the result of query().

Rev: lib/modules/Sql.pmod/sql.pike:1.31
  • Loading branch information
grubba committed Jun 27, 1999
1 parent a4792fc commit 1e1a5b4
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions lib/modules/Sql.pmod/sql.pike
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* $Id: sql.pike,v 1.30 1999/06/14 22:14:42 grubba Exp $
* $Id: sql.pike,v 1.31 1999/06/27 21:36:39 grubba Exp $
*
* Implements the generic parts of the SQL-interface
*
Expand All @@ -8,7 +8,7 @@

//.
//. File: sql.pike
//. RCSID: $Id: sql.pike,v 1.30 1999/06/14 22:14:42 grubba Exp $
//. RCSID: $Id: sql.pike,v 1.31 1999/06/27 21:36:39 grubba Exp $
//. Author: Henrik Grubbström (grubba@idonex.se)
//.
//. Synopsis: Implements the generic parts of the SQL-interface.
Expand Down Expand Up @@ -276,19 +276,23 @@ static private array(mapping(string:mixed)) res_obj_to_array(object res_obj)
array(mapping(string:mixed)) res = ({});
array(string) fieldnames;
array(mixed) row;


array(mapping) fields = res_obj->fetch_fields();

fieldnames = Array.map(res_obj->fetch_fields(),
lambda (mapping(string:mixed) m) {
if (case_convert) {
return(lower_case(m->name)); /* Hope this is even more unique */
} else {
return(m->name); /* Hope this is unique */
}
} );
return((m->table||"") + "." + m->name);
} ) +
fields->name;

if (case_convert) {
fieldnames = Array.map(fieldnames, lower_case);
}

while (row = res_obj->fetch_row()) {
res += ({ mkmapping(fieldnames, row) });
res += ({ mkmapping(fieldnames, row + row) });
}

return(res);
} else {
return(0);
Expand Down

0 comments on commit 1e1a5b4

Please sign in to comment.