I have a single cffunction which returns multiple queries. I'm using 'struct' as my returntype. My question is, how do I use function returns in multiple cfselects. I can get the cfdump to work, but not sure what to put in
cfc
<cffunction name="cfcName" access="remote" returntype="struct">
<cfset var myStruct=StructNew()>
<!---Query1---->
<cfquery name="Query1" datasource="dsn">
SELECT DISTINCT Col1
FROM Table1
ORDER BY Col1
</cfquery>
<!---Query2---->
<cfquery name="Query2" datasource="dsn开发者_运维知识库">
SELECT DISTINCT Col2
FROM table2
ORDER BY Col2
</cfquery>
<cfset myStruct.Query1= Query1>
<cfset myStruct.Query2= Query2>
<cfreturn myStruct>
</cffunction>
<cfinvoke
component="CMPT"
method="cfcName"
returnvariable="Return_cfcName">
</cfinvoke>
cfm,
(Query 1 returns should diplay in this cfselect)
<cfselect name="Select1" required="no" query="?" value="?" display="?" queryPosition="below">
<option value="">ALL</option>
</cfselect>
(Query 2 returns should diplay in this cfselect)
<cfselect name="Select2" required="no" query="?" value="?" display="?" queryPosition="below">
<option value="">ALL</option>
</cfselect>
Any help is appreciated, thanks in advance.
This should do the trick...
<cfselect name="Select1" required="no" query="Return_cfcName.Query1" value="Col1" display="Col1" queryPosition="below">
<option value="">ALL</option>
</cfselect>
<cfselect name="Select2" required="no" query="Return_cfcName.Query2" value="Col2" display="Col2" queryPosition="below">
<option value="">ALL</option>
</cfselect>
精彩评论