且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在冷融合中使用 CFQuery 执行 2 个或更多插入语句?

更新时间:2023-09-02 23:25:22

在数据源设置中,您可以通过维护连接设置告诉它是否保持连接打开.

Within the data source settings you can tell it whether to keep connections open or not with the Maintain Connections setting.

我相信,从一开始,ColdFusion 8 数据源就被设置为一次只运行一个查询,因为存在 SQL 注入问题.要更改此设置,您需要使用连接字符串进行修改.

Starting with, I believe, ColdFusion 8 datasources are set up to run only one query at a time due to concerns with SQL injection. To change this you would need to modify with the connection string.

***的办法是打开维护连接,如果需要,使用 cftransaction:

Your best bet is to turn on Maintain Connections and if needed use cftransaction:

<cftransaction>
<cfquery name="ins" datasource="dsn">
insert into table1 values(<cfqueryparam value="#url.x#">)
</cfquery>
<cfquery name="ins" datasource="dsn">
insert into table2 values(<cfqueryparam value="#url.x#">)
</cfquery>
</cftransaction>

始终,始终对用户提交的值使用 cfqueryparam.

And always, always use cfqueryparam for values submitted by users.