Been mucking around with variables again. Looks like the ColdFusion MX query object can now hold complex values. To my surprise you can now bung in structures, arrays and even other query objects. Not entirely sure what weird and wonderful things one might try now that this is possible but there it is.
I've put together a snapshot of a complex query object dump and a snippet of code if anyone is interested in playing. Any comments on cunning ideas for how you might use this in a real world scenario welcome.
Just cut and paste the following code snippet to play.
<cfquery datasource="cfsnippets" name="qCourses">
SELECT course_id, descript, number FROM Courses
WHERE number LIKE '5%'
</cfquery>
<cfscript>
// structure
a.b.cats = "Cats in hats.";
x.y.zapper = "Zap the zephyr.";
setVariable("a.b.LookAtTheCase", "See that the casing is preserved");
a.b['LookAtThisToo'] = "Again the casing is preserved";
a.b.x = x;
// array
aArray = ArrayNew(1);
aArray[1] = "uno";
aArray[2] = "duo";
// query
q = QueryNew("col1, col2");
QueryAddRow(q, 1);
QuerySetCell(q, "col1", "bah");
QuerySetCell(q, "col2", "foo");
// add to our main query
QueryAddRow(qCourses, 1);
QuerySetCell(qCourses, "course_id", q);
QuerySetCell(qCourses, "descript", a);
QuerySetCell(qCourses, "number", aArray);
</cfscript>
<cfdump var="#qCourses#" label="Complex Query Variables">
There have been other subtle changes to ColdFusion variables such as smart structures.
Posted by modius at 10:00 PM | Permalink
Trackback: http://blog.daemon.com.au/cgi-bin/dmblog/mt-tb.cgi/23


Found only this small tidbit in the CFMX docs that alludes to this feature.
"Note: When you create a record set, you can store in it complex objects, such as arrays and structures. However, you cannot use Query Of Queries on a record set that contains complex objects. For more information on Query of Queries, see "About Query of Queries"."
Posted by: modius on July 19, 2002 10:06 PM
Weird that you can't do a query of queries on that recordset. I guess you'd have to pull that recordset local before attempting QofQ on it.
Posted by: Todd on July 19, 2002 10:37 PM
Hey modius, on a different yet same sort of topic... check this out:
http://blog.web-rat.com/archives/000020.cfm
Posted by: Todd on July 20, 2002 12:23 AM
That link on blog.web-rat.com is invalid.
Posted by: Chris on April 11, 2003 02:42 AM