Referencing an array of queries in a cfloop
I am trying to reference a query from an array and use it in a cfloop tag and I keep getting an error
Error:
The expression has requested a variable or an intermediate expression result as a simple value. However, the result cannot be converted to a simple value. Simple values are strings, numbers, boolean values, and date/time values. Queries, arrays, and COM objects are ex开发者_开发问答amples of complex values.
The most likely cause of the error is that you tried to use a complex value as a simple one. For example, you tried to use a query variable in a cfif tag.
Code:
<cfquery datasource="datasource" name="valueQuery">SELECT count FROM watermelons</cfquery>
<cfset queryArray = ArrayNew(1)>
<cfscript>
ArrayAppend(queryArray, valueQuery);
</cfscript>
<cfloop query="#queryArray[1]#">
<!---do stuff--->
</cfloop>
I have also tried (without the pounds):
<cfloop query="queryArray[1]">
<!---do stuff--->
</cfloop>
which gives this error:
The value of the attribute query, which is currently queryArray[1], is invalid.
<cfset queryIndex = queryArray[1]>
<cfloop query="queryIndex">
<!---do stuff--->
</cfloop>
'cause query=""
expects a variable name.
精彩评论