问题描述
当对cfqueryparam或cfprocparam进行编码时,cfsqltype是可选的。然而,我通常看到它编码。指定cfsqltype是否有什么好处?
When coding a cfqueryparam or cfprocparam, cfsqltype is optional. However, I've usually seen it coded. Are there any benefits to specifying cfsqltype?
推荐答案
主要好处是对查询输入进行额外级别的健康检查将它传递到您的查询。此外,在日期时间值的情况下,如果指定了cfsqltype =CF_SQL_DATE或=CF_SQL_TIMESTAMP,我相信CF将正确地将datetime字符串转换为正确的数据库格式。
The main benefit is an additional level of sanity checking for your query inputs, prior to passing it into your query. Also, in the case of date time values, I believe CF will properly translate datetime strings into the proper database format, if the cfsqltype="CF_SQL_DATE" or ="CF_SQL_TIMESTAMP" is specified.
此外,我认为这使得未来的开发人员更清楚地看到当他们阅读你的代码时,除了这些类型。
In addition, I think it makes it more clear for future developers to see the types excepted when they read your code.
这篇关于是否使用cfsqltype好的做法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!