cfqueryparam中存在Struckt键吗? [英] Struckt Key Exists in cfqueryparam?
问题描述
我有带有checkbox
字段的表单字段.在我的cfc
页面上,当我运行插入/更新查询时,我想使用strucktKeyExists
来检查复选框表单字段是否存在.我的cfqueryparam
中也有null
属性,如果值/字段不存在,该属性会将值设置为true/false.这是我的代码示例:
I have form fields with checkbox
fields. On my cfc
page I would like to use strucktKeyExists
to check if checkbox form fields exist when I run my Insert/Update query. Also I have null
attribute in my cfqueryparam
that will set value to true/false if value/field doesn't exist. Here is example of my code:
dm_ck0 = <cfqueryparam value="#trim(structKeyExists(FORM, 'frm_ck0'))#" cfsqltype="cf_sql_bit" maxlength="1" null="#yesNoFormat(!len(trim(structKeyExists(FORM, 'frm_ck0'))))#" />
因此,当我提交表单时,checkbox
字段为unchecked
.我收到一条错误消息:
So when I submit my form checkbox
field is unchecked
. I got an error message back:
Invalid data value NO exceeds maxlength setting 1.
我不确定为什么会显示此消息.在我在cfqueryparam
中设置StrucktKeyExist()
之前,我的代码可以正常工作.如果有人看到我的代码失败了,请告诉我.谢谢!
I'm not sure why this message showed up. Before I set StrucktKeyExist()
in my cfqueryparam
my code worked fine. If anyone see where my code is failing please let me know. Thanks!
推荐答案
首先,设置变量:
myVar = structKeyExists(FORM, 'frm_ck0') ? 1 : 0;
在查询参数中使用变量
dm_ck0 = <cfqueryparam value="#myVar#" cfsqltype="cf_sql_bit">
这篇关于cfqueryparam中存在Struckt键吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!