returning multiple stored procedure result sets from a cfc

和自甴很熟 提交于 2019-12-05 20:51:27
jim collins

I would create other methods in the CFC that would each be responsible for returning a result from the stored proc. In the main method , call setters setProfileHead(profilehead:profileHead)

<cffunction name=ProfileHead>
    <cfarguments name=ProfileHead />
    <cfset variables.profilehead = arguments.profilehead>
 </cffunction>

Then...

<cffunction name=GetProfileHead>
    <cfreturn variables.profileHead />
</cffuction>

A function can only return a single value. If you wish to return multiple values, you will need to use some type of complex object (an array, structure, ...) If arrays are not intuitive enough, you could place the queries in a structure and return that instead. Then the calling page could access the queries by name, rather than index.

(Side note, be sure to properly var scope/localize all function variables.)

 <cfset var data = {}>
 ...
 <!--- store query results in structure --->
 <cfset data.profile_head = profile_head>
 <cfset data.attribution = attribution>
 ... 
 <cfset data.holdings = holdings>
 <!--- return structure --->
 <cfreturn data>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!