Can I queryparam a string used in a MySQL IN statement using ColdFusion?

不想你离开。 提交于 2019-12-11 11:13:36

问题


I'm running MySQL 5.0.88 and Coldfusion8.

In a form, I'm grabbing a number of record ids from a table and send them to the server. The string will look like so:

 9900000002985,9900000003180,9900000003203,9900000003487,9900000003579

I'm then passing this into MySQL, initially like so:

SELECT bk.*
   FROM header AS bk
   WHERE 1
   AND bk.iln_kaeufer IN ( #passed_in_string# )

I have been trying for a while to use cfqueryparam like so:

<cfqueryparam cfsqltype="cf_sql_longvarchar" value="#passed_in_string#">

But this causes an error in ColdFusion. Whereas if I run the query directly in MySQL, it works. So it must be something with my cfqueryparam declaration.

I'm passing this form through AJAX from a remote location. So I don't get any error messages except for an AJAX commit error.

Question:
How do I secure the above string if I can't use cfqueryparam?

Thanks!


回答1:


You want to use the list and separator parameters of cfqueryparam.

SELECT bk.*
  FROM header AS bk
  WHERE 1
    AND bk.iln_kaeufer IN ( <cfqueryparam list="yes" separator="," cfsqltype="cf_sql_longvarchar" value="#passed_in_string#">)


来源:https://stackoverflow.com/questions/11722181/can-i-queryparam-a-string-used-in-a-mysql-in-statement-using-coldfusion

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