CFC 将多个查询返回给 cfselect
我有一个返回多个查询的 cffunction。我使用“struct”作为我的返回类型。我的问题是,如何在多个 cfselect 中使用函数返回。我可以让 cfdump 工作,但不确定要放入什么内容,
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>
如有任何帮助,我们将不胜感激,提前致谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这应该可以解决问题...
This should do the trick...