问题标签 [cfqueryparam]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
1028 浏览

coldfusion - ColdFusion 9: int and type="numeric" nasty bug?

I've just experienced a behaviour that defies any logic and could potentially lead to serious issues and was wondering if it was a bug or if the behaviour was itended and what are the best practices to circumvent the issue? If it's a bug, is there a patch?

Here's the two wierd behaviours that when put together are a threat to any system's data integrity.

  1. int('1 2') -> 41276
  2. isValid('numeric', '1 2') -> true

Why? Well let's see...

Here, the type="numeric" arguments validation (which perhaps is based on the same algorithm as isValid?) doesn't throw with '1 2'. Even worse, cfqueryparam cfsqltype="cf_sql_integer" seems to be using int to convert the value which will end up being 41276.

In other words, deleteSomething('1 2') will delete the entity with id 41276 instead of throwing an exception since the value 1 2 is obviously not numeric.

Now, the only fix I thought of is to perform additionnal argument validation using isValid('integer', ... or a regular expression, but that's a real pain and besides, I never understood why they haven't implemented type="integer"?

Obviously, I also always made the false assumption that cfqueryparam type="cf_sql_integer" would validate that the value passed is a valid integer.

EDIT:

It seems that even isvalid('integer', ... is also not reliable as we can see in
Why isvalid("integer","1,5") = YES?

EDIT2:

I know that I could add additionnal arguments validation for every expected integer argument in every function, however that would require to fix a huge code base in my case and it's also very error-prone. It also makes the built-in argument validation completely useless in this case.

I would rather prefer a solution where I could create and apply an unofficial patch. Is that a realistic option? If so I would like to be pointed out in the right direction.

EDIT3: It doesn't solves all the problems, but CF11 added support for a strictNumberValidation application level configuration.

"Starting from ColdFusion 11, this function evaluates on a more strict basis. Setting this value to false makes the isValid function to behave in the older way. This setting effects cfargument, cfparam and cfform tags wherever integer & numeric validation is used. Based on this setting, the validation reflects in those tags as well."

0 投票
1 回答
384 浏览

tsql - 在超过 2100 个值上选择 IN

如何在超过 2100 个值上进行选择?

由于表的设置方式,链接服务器和连接不是一个选项。

运行时会抛出一个错误,因为传入了许多新字段。

0 投票
1 回答
277 浏览

coldfusion - 使用多个 cfqueryparam 时,cfquery 不返回结果

cfquery使用多个时,ColdFusion 中会出现以下错误cfqueryparams;但是,当它们不被使用或仅限于其中一种时,查询会返回预期的结果:

数据通过如下所示的 URL 传入:

该查询已在 SQLPlus 中使用有效数据进行了测试,并且也返回了预期的结果。这个问题似乎仅限于通过传递值的时间,URL尽管通过 post 传递它们并且FORM工作正常,所以我怀疑 URL 中的某些内容以某种方式被破坏了。数据和查询已经过检查,cfdump并且与在 SQLPlus 中运行查询所用的内容相比,一切看起来都是正确的。

数据库后端是 Oracle 11g,据我所知,所有相关驱动程序都是最新的。关于这里可能发生什么的任何想法,因为似乎已经检查了明显的问题。

0 投票
1 回答
272 浏览

coldfusion - ColdFusion 使用 cfqueryparam 循环查询

我正在尝试使用嵌套查询循环查询。我到目前为止的代码:

我遇到的问题是它不会通过 cfqueryparam 动态循环。它只是从 hashTableLatest 中获取第一个值。谁能告诉我我做错了什么?如何循环查询并动态更改 cfqueryparam?

已编辑 要在单个查询中获取我需要的所有信息:

我认为上面的 SQL 应该能得到我需要的所有信息。我正在寻找的结果是获取所有不同的 imageHashes

0 投票
1 回答
584 浏览

mysql - Coldfusion MYSQL日期查询参数不返回结果

我刚刚遇到了我认为一定是coldfusion错误。

我有一个查询:

问题是,如果我通过第二个日期变量,则不会返回任何内容。如果我将查询前缀 SQL 和参数复制出来并直接查询数据库,则返回结果。只是当它通过CF时它不起作用。如果我删除第二个日期参数它工作正常。如果我将第二个日期参数转换为字符串,它将起作用。

我尝试将第二个参数的值交换为 now() 也不起作用。

据我所知,问题在于第二个日期参数是日期类型。

我是否在做任何我不知道的明显错误的事情?

startDate 和 endDate 变量是冷融合日期时间对象。CallTime 是 MariaDB 中的 dateTime 列。

0 投票
2 回答
973 浏览

tsql - Is there any logical reason to use CFQUERYPARAM in Query of Queries?

I primarily use CFQUERYPARAM to prevent SQL injection. Since Query-of-Queries (QoQ) does not touch the database, is there any logical reason to use CFQUERYPARAM in them? I know that values that do not match the cfsqltype and maxlength will throw an exception, but, these values should already be validated before that and display friendly messages (from a UX viewpoint).

0 投票
0 回答
205 浏览

sql-server - 如何在查询文本中包含传递给 SQL Server 的查询参数作为注释?

由于您无法在 SQL Server 中获取正在运行的查询的参数值,因此我正在考虑以注释的形式将参数值附加到查询中,然后通过 sp_who2 可见。例如,如果我有这个查询:

我会在提交之前将参数附加到查询中,以便将其传递给数据库,如下所示:

我知道 CFParam 返回传入的参数数组,但这只是在返回查询结果之后。在将查询传递到数据库之前,我该如何做呢?

谢谢!

0 投票
1 回答
4297 浏览

sql - 如何将 cfqueryparam 用于空值以从表中获取记录?

我可以将 cfqueryparam 用于空值以从表中获取记录吗?

我的示例选择查询是

Dan Bracuk 的编辑从这里开始

以下是针对 oracle 数据库的示例查询:

这是来自网页的调试。

你如何解释这个?是不是这样:

或这个

0 投票
1 回答
921 浏览

oracle - ColdFusion - cfproc 参数:如何使用 db 定义的变量 %TYPE 调用存储过程?

我在 Oracle 中有一个存储过程。其中一个输入参数是定义的类型(见下文)。每当我调用 cfstoredproc 时出现的错误是“表达式的类型错误 ORA-06550”。它是一个格式化的 varchar,它是一个表格列。没有与之匹配的 CFPROCPARAM 类型。

类型是包定义的特定格式(表列):EMAIL_ADDRESSES_TABLE.USER_ID%TYPE。表列 USER_ID 为:USER_ID VARCHAR2(8 BYTE)

USER_ID 是一个用 0 填充的数字,例如 '00001234'

我的电话:

存储过程函数:

我从系统得到的错误是:

0 投票
1 回答
345 浏览

coldfusion - 将 cfqueryparam 与常量一起使用

我们虔诚地cfqueryparam在我们的 SQL 查询中使用。

我的一些前辈在使用直接值而不是变量时似乎有点过分热心。

不是吗

矫枉过正?我的意思是,没有 SQL 注入的机会,而且我认为在这里使用绑定变量对提高数据库性能没有任何帮助。这样做岂不是同样合理吗

?

cfqueryparam除了养成使用它的习惯之外,在这种情况下使用它有什么好处吗?有缺点吗?