1

将表单范围传递到具有 access="remote" 的 cfc 的语法是什么?我有:

<cfcomponent>
<cfset Variables.Datasource = "xxx">

<cffunction name="Save" access="remote">
    <cfset var local = {}>

    <!--- todo: try/catch --->  
    <cfif arguments.PersonID>
        <cfquery datasource="#Variables.Datasource#">
        UPDATE Person
        SET FirstName = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.FirstName#">
        ,LastName = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.LastName#">
        WHERE PersonID = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.PersonID#">
        </cfquery>
        <cfset local.result = arguments.PersonID>
    <cfelse>
        <cfquery name="local.qry" datasource="#Variables.Datasource#">
        INSERT INTO Person(FirstName,LastName) VALUES(
        <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.FirstName#">
        ,<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.LastName#">
        );
        SELECT PersonID FROM Person 
        WHERE PersonID=Scope_Identity()
        </cfquery>
        <cfset local.result = local.qry.PersonID>
    </cfif>
    <cfreturn local.result>
</cffunction>
</cfcomponent>

我需要传入form.PersonID、form.firstname、form.lastname。

4

2 回答 2

1

一件不相干的事。在 cf9 中,您已经等待本地结构。更多关于这里http://forta.com/blog/index.cfm/2009/6/21/The-New-ColdFusion-LOCAL-Scope

于 2010-03-30T07:40:35.970 回答
1

您的远程函数可以接受 struct 参数或 3 个字符串参数(PersonID、firstname 和 lastname)。

<CFARGUMENT>文档

于 2010-03-30T01:11:54.490 回答