我已经做了一段时间了,并想出一组额外的眼睛(即你们)可能会派上用场。我已经定义了一个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标签中调用它,但我得到相同的结果。我确定我在这里遗漏了一些非常基本的东西。
答案 0 :(得分: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>