ColdFusion函数中的论点



我被告知cffunction的参数不超过3个参数 - 有没有更好的方法来编写此功能?每个参数都是上一个窗口上可能的过滤器,用于在Whater子句中过滤结果。

<cffunction name="Example" access="remote" returntype="query">
    <cfargument name="keyword" type="string">
    <cfargument name="office" type="numeric">
    <cfargument name="builder" type="numeric">
    <cfargument name="sup" type="numeric">
    <cfargument name="mgr" type="numeric">

您在问题中拥有的代码比以下建议更好:

<cfargument type="struct">

原因是结构可以包含任何东西,并且不仅限于该函数真正需要的内容。在问题中,它确实需要一个字符串和四个数字。

话虽如此,您仍然可以将结构(例如URL(传递给您的功能。这是一个简单的事情:

myQuery = Example(argumentCollection = url);

最新更新