Skip to content
Snippets Groups Projects
Commit 1e1a5b4a authored by Henrik (Grubba) Grubbström's avatar Henrik (Grubba) Grubbström
Browse files

res_obj_to_array() now also adds <table>.<column> entries to the result 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
parent a4792fcd
No related branches found
No related tags found
No related merge requests found
/* /*
* $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 * Implements the generic parts of the SQL-interface
* *
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
//. //.
//. File: sql.pike //. 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 Grubbstrm (grubba@idonex.se) //. Author: Henrik Grubbstrm (grubba@idonex.se)
//. //.
//. Synopsis: Implements the generic parts of the SQL-interface. //. Synopsis: Implements the generic parts of the SQL-interface.
...@@ -277,18 +277,22 @@ static private array(mapping(string:mixed)) res_obj_to_array(object res_obj) ...@@ -277,18 +277,22 @@ static private array(mapping(string:mixed)) res_obj_to_array(object res_obj)
array(string) fieldnames; array(string) fieldnames;
array(mixed) row; array(mixed) row;
array(mapping) fields = res_obj->fetch_fields();
fieldnames = Array.map(res_obj->fetch_fields(), fieldnames = Array.map(res_obj->fetch_fields(),
lambda (mapping(string:mixed) m) { lambda (mapping(string:mixed) m) {
return((m->table||"") + "." + m->name);
} ) +
fields->name;
if (case_convert) { if (case_convert) {
return(lower_case(m->name)); /* Hope this is even more unique */ fieldnames = Array.map(fieldnames, lower_case);
} else {
return(m->name); /* Hope this is unique */
} }
} );
while (row = res_obj->fetch_row()) { while (row = res_obj->fetch_row()) {
res += ({ mkmapping(fieldnames, row) }); res += ({ mkmapping(fieldnames, row + row) });
} }
return(res); return(res);
} else { } else {
return(0); return(0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment