I don't know if this is a bug, undocumented feature or correct behavior?
But has anybody run into this before?

I have some code such as this in a CFC creating an array of queries.

<!--- 
      *******************
        Pseudo code example 
      *******************
  --->

<cfset QueryAry = ArrayNew(1)>

<!--- This query will return one record --->
<cfquery name="First" datasource="DSN">
        SELECT Field1, Field2, Field3
        FROM     Table1
        WHERE  ID = #IDVar#
</cfquery>
<cfset QueryAry[1] = First>

<!--- This query will return zero to many records --->
<cfquery name="Second" datasource="DSN">
        SELECT Field4, Field5, Field6
        FROM     Table2
        WHERE    ID = #IDVar#
</cfquery>
<cfset QueryAry[2] = Second>

<cfreturn QueryAry>

Then when I try to output the query results stored in the array returned
from the CFC.

<cfoutput>
        #IsQuery(QueryAry[1])# <!--- This returns True --->
        #IsQuery(QueryAry[2])# <!--- This returns True --->
</cfoutput>

<!--- Case 1: This does not work --->
<cfoutput query="QueryAry[1]">
        #Field1#
        #Field2#
        #Field3#
</cfoutput>

<cfoutput query="QueryAry[2]">
        #Field4#
        #Field5#
        #Field6#
</cfoutput>
<!--- End Case 1 --->

<!--- Case 2: This does not work --->
<cfloop query="QueryAry[1]">
        #Field1#
        #Field2#
        #Field3#
</cfloop>

<cfloop query="QueryAry[2]">
        #Field4#
        #Field5#
        #Field6#
</cfloop>
<!--- End Case 2 --->

<!--- Case 3: This does work --->
<cfoutput>
        #QueryAry[1]["Field1"][1]#
        #QueryAry[1]["Field2"][1]#
        #QueryAry[1]["Field3"][1]#
</cfoutput>

<cfloop from="1" to="#QueryAry[2].RecordCount#" index="i">
        <cfoutput>
                #QueryAry[2]["Field4"][i]#
                #QueryAry[2]["Field5"][i]#
                #QueryAry[2]["Field6"][i]#
        </cfoutput>
</cfloop>
<!--- End Case 3 --->

<!--- *** End Pseudo Code Example *** --->

I would be interested in any comments on this behavior by others in the CF
community, as well as Macromedia types if they care too say something.

--------------
Ian Skinner
Web Programmer
BloodSource
Sacramento, CA

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to