0

我已经为此工作了一段时间,并认为多一双眼睛(即你们)可能会派上用场。我已经定义了一个 mySQL 插入查询,该查询将在稍后调用和传递变量的 cffunction 中执行。cf 代码运行良好,但每当我去数据库查看代码是否已通过时,我都看不到任何数据被保存。我知道数据库本身很好,因为所有其他 mySQL 查询都按预期的方式工作。也许我在函数中调用了错误的参数?这是有问题的代码:

<cffunction name='sendToDiffQry'>
    <cfargument name="loanid" type="any" required="yes"/>
    <cfargument name="oldValue" type="any" required="yes"/>
    <cfargument name="newValue" type="any" required="yes" />
    <cfargument name="fieldName" type="string" required="yes" />

    <cftransaction>

            <cfquery name="diffInsert" datasource="STLinux1MySQL" result="diff">
             INSERT into tax_search_diff_table
                (
                tax_search_loan_id,
                 old_value,
                 new_value,
                 field_name,
                 timeofedit
                )
                VALUES
                (
                <cfqueryparam value="#trim(Val(loan_id))#" cfsqltype="cf_sql_bigint">,
            <cfqueryparam value="#trim(oldValue)#" cfsqltype="cf_sql_varchar">,
             <cfqueryparam value="#trim(newValue)#" cfsqltype="cf_sql_varchar">,
             <cfqueryparam value="#trim(fieldName)#" cfsqltype="cf_sql_varchar">,
             Now()

                ) 
            </cfquery> 

        </cftransaction>
</cffunction>

这就是我所说的:

<cfset
        sendToDiffQry(url.tax_search_loan_id, form.old_frequency_id, form.frequency_id, 'frequency')>

我知道我也可以在 cfoutput 标签中调用它,但我得到了相同的结果。我确定我在这里遗漏了一些非常基本的东西。

4

1 回答 1

0

对于tax_search_loan_id 列,您将参数作为loanid 并在cfqueryparam 中用作loan_id,所以试试这个代码

<cffunction name='sendToDiffQry'>
  <cfargument name="loanid" type="any" required="yes"/>
  <cfargument name="oldValue" type="any" required="yes"/>
  <cfargument name="newValue" type="any" required="yes" />
  <cfargument name="fieldName" type="string" required="yes" />

    <cfquery name="diffInsert" datasource="STLinux1MySQL" result="diff">

       INSERT into tax_search_diff_table
       (
        tax_search_loan_id,
        old_value,
        new_value,
        field_name,
        timeofedit
       )
       VALUES
       (
        <cfqueryparam value="#trim(Val(arguments.loanid))#" cfsqltype="cf_sql_bigint">,
        <cfqueryparam value="#trim(arguments.oldValue)#" cfsqltype="cf_sql_varchar">,
        <cfqueryparam value="#trim(arguments.newValue)#" cfsqltype="cf_sql_varchar">,
        <cfqueryparam value="#trim(arguments.fieldName)#" cfsqltype="cf_sql_varchar">,
        <cfqueryparam value="#Now()#" cfsqltype="cf_sql_varchar">
       ) 

 </cfquery> 
</cffunction>
于 2013-10-18T14:36:31.687 回答