From 1e1a5b4a89bad32c3be7d0554d7727b60e1c8b54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Sun, 27 Jun 1999 23:36:39 +0200 Subject: [PATCH] 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 --- lib/modules/Sql.pmod/sql.pike | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/modules/Sql.pmod/sql.pike b/lib/modules/Sql.pmod/sql.pike index 10d6d156e2..2486c52e5c 100644 --- a/lib/modules/Sql.pmod/sql.pike +++ b/lib/modules/Sql.pmod/sql.pike @@ -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 * @@ -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. @@ -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); -- GitLab