Coldfusion(mx7 及更高版本)有哪些“陷阱”?我应该知道什么?

发布于 2024-11-16 21:11:28 字数 754 浏览 1 评论 0原文

可能的重复:
ColdFusion 程序员需要避免的常见编程错误?

我刚刚花了花了半天时间对 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

依 靠 2024-11-23 21:11:28
  • 数组是按值传递的!
  • 对于某些 ORM 相关操作/注释区分大小写
  • serializeJSON() 可能*会意外地弄乱您的数据,例如'yes' --> 'true'1 --> 1.0
  • 可能没有告诉您真相
  • null[empty string] 在查询对象中是相同的
  • CF9 不太支持 SOAP 1.2,等到 CF10 到来时
  • ,一些结构看起来像结构,但它们并不是真正的结构(例如 cfcatch ),
  • 远程方法将在新的结构中被调用包含 CFC 的实例,因此不要指望实例变量已准备好使用
  • var 作用域不如 local。 有时当它被定义为多个时在同一函数中,
  • 三元运算符可能会评估您的内联数组/结构体文字,如果该数组/结构体内部的内容未定义,则抛出异常
  • ;, bar() 是即使定义了 foo 也总是被调用,
  • 可能会意外地遇到未记录的保留字: http://www.coldfusionjedi.com/index.cfm/2011/5/9/Interesting-issue-with-reserved-function-names-inside-CFCs
  • CF ajax 标签和 jQuery 不支持 在这里混合
  • 更多:ColdFusion 程序员要避免的常见编程错误?
  • 和甚至更多:ColdFusion 9 中需要注意的事项与CF-ORM
  • Arrays are pass-by-value!
  • case-sensitive for certain ORM related operations / annotations
  • serializeJSON() may* mess up your data unexpectedly e.g.'yes' --> 'true', 1 --> 1.0
  • <cfdump> may not be telling you the truth
  • null and [empty string] is the same in a query object
  • CF9 doesn't support SOAP 1.2 very well, wait til CF10 arrives
  • some structs looks like structs, but they're not really struct (e.g. cfcatch )
  • remote methods will get invoked in a new instance of the containing CFC, so don't count on instance variables being ready to be used
  • var scope doesn't work as well as local. sometimes when it is defined multiple times in the same function
  • the ternary operator may evaluate your inline array/structure literal and throw exception if things inside that array/structure is not defined
  • <cfparam name="foo" default="#bar()#">, bar() is always invoked even though foo is defined
  • might accidentally run into undocumented reserved words: http://www.coldfusionjedi.com/index.cfm/2011/5/9/Interesting-issue-with-reserved-function-names-inside-CFCs
  • CF ajax tags and jQuery don't mix
  • more here: Common programming mistakes for ColdFusion programmer to avoid?
  • and even more here: Things to watch out for in ColdFusion 9 with CF-ORM
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文