在结构中找不到qryname14411键 [英] Cannot find qryname14411 key in structure

查看:212
本文介绍了在结构中找不到qryname14411键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个错误,似乎与< cfscript> db操作相关

  //流量追踪
myQry = new Query();
myQry.setSQL(INSERT INTO dbo.Traffic(Circuit,Fuseaction,IP_hash)VALUES(:circuit,:fuseaction,:ip_hash));
myQry.addParam(name =circuit,value =#listfirst(rc.fuseaction,'。')#,cfsqltype =CF_SQL_VARCHAR);
myQry.addParam(name =fuseaction,value =#listlast(rc.fuseaction,'。')#,cfsqltype =CF_SQL_VARCHAR);
myQry.addParam(name =ip_hash,value =#cgi.remote_addr#,cfsqltype =CF_SQL_VARCHAR);
myQry.execute();

真奇怪的是,它看起来像操作完成。这是什么错误?



简短回答:这可能是一个范围界定问题。尝试:

  var myQry = new Query(); 



长线waffley答案



我把它称为Adobe开发者,是无用的错误。



在该文件的第460行,您将看到错误是由于StructFind未能在变量范围中查找查询名称,以及它出现在调试输入中的原因是因为有一个try / catch类型任何环绕它。通过用< cfif StructKeyExists(variables,tagAttributes ['name'])>替换try / catch,可以实现相同的功能而不会 code>这是基本的CFML知识,肯定是CF产品的开发人员应该知道的!



CF10版本的基础上仍然存在相同的代码。 cfc,因此您可能会或不愿意将其作为Adobe的 CF bugbase 中的错误提交 - 虽然它不太可能修复它的CF9(并且不确定他们是否会觉得CF10值得努力)。



但是,这只会是侧面的变量的问题不存在,不解决真正的问题为什么它实际上不存在。鉴于调试信息显示查询已成功执行,并且查询代码基本上位于该行上方(从第442行开始),因此它不应是重复/常见错误,但可能是由于您的 myQry 变量没有作用域,因此它可能与另一个也称为myQry的变量(或者甚至是从函数的单独调用中的相同变量)正在执行新的Query() .execute()行之间,从而导致原始查询



解决方案是将关键字 var 在第一次使用 myQry 之前,它将它放在该函数的本地作用域中 - 应该对所有变量执行,一个函数的实例,(否则它们被放置在该函数存在的组件/请求的变量范围内)。


I have an error that seems to be associated with <cfscript> db operation

// traffic tracking
myQry = new Query();
myQry.setSQL("INSERT INTO   dbo.Traffic (Circuit, Fuseaction, IP_hash) VALUES   (:circuit, :fuseaction, :ip_hash)");
myQry.addParam(name="circuit",      value="#listfirst(rc.fuseaction, '.')#",    cfsqltype="CF_SQL_VARCHAR");
myQry.addParam(name="fuseaction",   value="#listlast(rc.fuseaction, '.')#",     cfsqltype="CF_SQL_VARCHAR");
myQry.addParam(name="ip_hash",      value="#cgi.remote_addr#",                  cfsqltype="CF_SQL_VARCHAR");    
myQry.execute();

The really strange thing is, it looks like the operation completed. What kind of a error is this?

解决方案

Short answer: It's probably a scoping issue. Try:

var myQry = new Query();


Long-winded waffley answer:

I'd call it an Adobe-developers-being-useless kind of error.

If you look at line 460 of that file, you'll see the error is due to a failure of StructFind to find the query name in the variables scope, and the reason it's appearing in debug input is because there's a try/catch with type any surrounding it. The same functionality could be achieved without causing/catching an error by replacing the try/catch with <cfif StructKeyExists(variables,tagAttributes['name']) > which is basic CFML knowledge, and certainly something a developer of the CF product should know!

The same code still exists in the CF10 version of base.cfc, so you may or not feel like submitting it as a bug in Adobe's CF bugbase - though it's unlikely they'll fix it for CF9 (and uncertain whether they'll feel CF10 is worth the effort either).

However, that would only be side-stepping the issue of the variable not existing, not addressing the real issue of why it doesn't actually exist. Given that the debug info shows the query is successfully executing, and the query code is basically right above that line (starts at line 442), it shouldn't be a repeated/common error, but it may be due to your myQry variable not being scoped, and thus it could be colliding with another variable also called myQry (or even the same var from a separate call to the function) which is happening between the execution of the new Query() and .execute() lines, and thus causing the original query to not be there when the StructFind looks for it.

The solution is to put the keyword var before the first use of myQry which will place it in the local scope for that function - something that should be done for all variables that are only for use within an instance of a function, (otherwise they are placed in the variables scope of the component/request that the function exists within).

这篇关于在结构中找不到qryname14411键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆