Struckt Key Exists in cfqueryparam?

送分小仙女□ 提交于 2019-12-24 11:37:14

问题


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'))))#" /> 

So when I submit my form checkbox field is unchecked. I got an error message back:

Invalid data value NO exceeds maxlength setting 1.

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!


回答1:


First, set the variable:

myVar = structKeyExists(FORM, 'frm_ck0') ? 1 : 0;

Use your variable in the query parameter

dm_ck0 = <cfqueryparam value="#myVar#" cfsqltype="cf_sql_bit">


来源:https://stackoverflow.com/questions/45944121/struckt-key-exists-in-cfqueryparam

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!