I am sorry, I was bad there.  I am just so in awe of you that it was nice to
think I knew someting for once :)

Again sorry man, I acted immature.

Tim

-----Original Message-----
From: Timothy Heald [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 29, 2002 10:12 PM
To: CF-Talk
Subject: RE: Help with using query with [] notation


Hey Dave,

        I have waited for a while for this :)  You can do this:

myQuery['col_id']['rowNumber']

        On CF 4.5 on Solaris at least.  It also works in CFMX on Win 2k.

My test code:

<CFQUERY name="getStuff" datasource="home">
        select * from guestbook
</CFQUERY>
<CFOUTPUT>
<CFLOOP list="#getStuff.columnlist#" index="i">
        <CFLOOP from="1" to="#getStuff.recordCount#" index="ii">
                #getStuff[i][ii]#<br>
        </CFLOOP>
</CFLOOP>

#getStuff['cFirstName'][3]#
</CFOUTPUT>

Tim
-----Original Message-----
From: Dave Watts [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 29, 2002 10:05 PM
To: CF-Talk
Subject: RE: Help with using query with [] notation


> I know it's possible to do something like this:
>     MyQuery["FieldName"]  (I know it's probably wrong, but
> serves the purpose here)

For the record, you can't do that, but you can do this:

MyQuery.FieldName[i]

to reference the column value at row i.

> The CF Documentation does mention this somewhere, but doesn't
> really go into detail. Does anyone know of any good links,
> articles, or resources that describe this in more detail???
> I'd prefer to understand this properly, rather than just find
> the "solution" for my current situation. Not to mention that
> it would be better if I can direct my coworkers and
> subordinates to these resources as well....

The only mention of it of which I'm aware is in the "Advanced ColdFusion
Development" course offered by MM, but I suspect it's in the docs somewhere.
However, there really isn't that much else to say about it, beyond the three
lines near the top of the message. You can reference a column's value for a
specific row using array notation.

Of course, how you use this is up to you. For example, if you wanted to
refer to the last row of a recordset, you could do it like this:

MyQuery.FieldName[MyQuery.RecordCount]

Or, you could use this feature to loop over the recordset in a CFSCRIPT
block, since there's nothing analogous to the QUERY attribute of CFOUTPUT
within CFSCRIPT:

<cfscript>
for (i = 1; i lte MyQuery.RecordCount; i = i + 1) {
        WriteOutput(MyQuery.FieldName[i] & "<br>");
}
</cfscript>

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
voice: (202) 797-5496
fax: (202) 797-5444


______________________________________________________________________
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to