In UDF format:
function queryRowToStruct(query){
//by default, do this to the first row of the query
var row = 1;
//a var for looping
var ii = 1;
//the cols to loop over
var cols = listToArray(query.columnList);
//the struct to return
var stReturn = structnew();
//if there is a second argument, use that for the row number
if(arrayLen(arguments) GT 1)
row = arguments[2];
//loop over the cols and build the struct from the query row
for(ii = 1; ii lte arraylen(cols); ii = ii + 1){
stReturn[cols[ii]] = query[cols[ii]][row];
}
//return the struct
return stReturn;
}
</cfscript>
Syntax : <cfdump var="#queryRowToStruct(Q,X)#">
Q = Query Object
X = Row you wish to transform
-----Original Message-----
From: Douglas Humphris [mailto:[EMAIL PROTECTED]
Sent: 21 January 2004 13:06
To: [EMAIL PROTECTED]
Subject: [ cf-dev ] Query to Struct
Hi all,
I'm trying to copy the contents of the first row of a resultset into a
structure without knowing the column names, but can't do it:
1. stValidLogin = Duplicate(qryGetUserCredentials[1])
2. stValidLogin = Duplicate(qryGetUserCredentials)
3. stValidLogin = StructCopy(qryGetUserCredentials[1])
4. stValidLogin = StructCopy(qryGetUserCredentials)
None of the above appears to work. How can I do this?
Thanks, Douglas
--
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED] For human
help, e-mail: [EMAIL PROTECTED]
This e-mail is from Reed Exhibitions (Oriel House, 26 The Quadrant,
Richmond, Surrey, TW9 1DL, United Kingdom), a division of Reed Business,
Registered in England, Number 678540. It contains information which is
confidential and may also be privileged. It is for the exclusive use of the
intended recipient(s). If you are not the intended recipient(s) please note
that any form of distribution, copying or use of this communication or the
information in it is strictly prohibited and may be unlawful. If you have
received this communication in error please return it to the sender or call
our switchboard on +44 (0) 20 89107910. The opinions expressed within this
communication are not necessarily those expressed by Reed Exhibitions.
Visit our website at http://www.reedexpo.com
--
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]