Coldfusion(mx7 及更高版本)有哪些“陷阱”?我应该知道什么?
我刚刚花了花了半天时间对 Coldfusion MX7 及以下版本显然是一个相当著名的陷阱进行故障排除:
嵌套查询循环错误:
您需要引用的current_row
外部查询,否则您将只能看到第一条记录。
例如:
<cfloop query="outer">
<cfloop query="innner">
<p>#outer.field#</p><!--- this won't work, you'll only get the first row --->
<p>#outer.field[current_row]#</p><!--- you must do this instead --->
</cfloop>
</cfloop>
还有其他方式使得 ColdFusion 无法以明显的方式工作吗?
Possible Duplicate:
Common programming mistakes for ColdFusion programmer to avoid?
I just spent half the day troubleshooting what is apparently a rather famous gotcha for Coldfusion MX7 and below:
The nested query loop bug:
Where you are required to reference the current_row
of the outer query or else you will only see the first record.
For example:
<cfloop query="outer">
<cfloop query="innner">
<p>#outer.field#</p><!--- this won't work, you'll only get the first row --->
<p>#outer.field[current_row]#</p><!--- you must do this instead --->
</cfloop>
</cfloop>
Are there any other ways in which ColdFusion does not work in the obvious way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
serializeJSON()
可能*会意外地弄乱您的数据,例如'yes' --> 'true'
,1 --> 1.0
可能没有告诉您真相null
和[empty string]
在查询对象中是相同的var
作用域不如local。
有时当它被定义为多个时在同一函数中,;
,bar()
是即使定义了 foo 也总是被调用,serializeJSON()
may* mess up your data unexpectedly e.g.'yes' --> 'true'
,1 --> 1.0
<cfdump>
may not be telling you the truthnull
and[empty string]
is the same in a query objectcfcatch
)var
scope doesn't work as well aslocal.
sometimes when it is defined multiple times in the same function<cfparam name="foo" default="#bar()#">
,bar()
is always invoked even though foo is defined