>From cflib.org I think:
<cfscript>
function queryToArrayOfStructures(theQuery){
var theArray = arraynew(1);
var cols = ListtoArray(theQuery.columnlist);
var row = 1;
var thisRow = "";
var col = 1;
for(row = 1; row LTE theQuery.recordcount; row = row + 1){
thisRow = structnew();
for(col = 1; col LTE arraylen(cols); col = col + 1){
thisRow[cols[col]] = theQuery[cols[col]][row];
}
arrayAppend(theArray,duplicate(thisRow));
}
return(theArray);
}
function arrayOfStructuresToQuery(theArray){
var colNames = "";
var theQuery = queryNew("");
var i=0;
var j=0;
//if there's nothing in the array, return the empty query
if(NOT arrayLen(theArray))
return theQuery;
//get the column names into an array =
colNames = structKeyArray(theArray[1]);
//build the query based on the colNames
theQuery = queryNew(arrayToList(colNames));
//add the right number of rows to the query
queryAddRow(theQuery, arrayLen(theArray));
//for each element in the array, loop through the columns,
populating the query
for(i=1; i LTE arrayLen(theArray); i=i+1){
for(j=1; j LTE arrayLen(colNames); j=j+1){
querySetCell(theQuery, colNames[j],
theArray[i][colNames[j]], i);
}
}
return theQuery;
}
</cfscript>
One other thing this is useful for is Java does not have a query data type
that matches CF's, but an array of hash maps in Java is an array fo
structures in CF.
Cheers
Mark
------------------
Mark Stanton
Technical Director
Gruden Pty Ltd
Tel: 9956 6388
Mob: 0410 458 201
Fax: 9956 8433
http://www.gruden.com
---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia
http://www.mxdu.com/ + 24-25 February, 2004