从查询设置 ColdFusion 动态应用程序变量
我胡思乱想,认为将我的应用程序变量移动到可以在ApplicationStart 上加载的表中会很好。
我的目的是允许 ANT 推出应用程序,并更改数据库和众所周知的急速中的一些设置。
在我的测试代码中,application.cfc 有一个简单的查询来调用所有变量名称,然后使用 cfloop 来调用将应用程序范围内的每个变量设置为 application.varname。
在ApplicationStart 上没有报告错误..但是尝试引用变量会出现未定义的类型错误。
我的蜘蛛感觉告诉我这是一些小而明显的事情......有什么想法吗?
谢谢!!
更新 1:看来我正在查看的是设置动态变量名称,而它们是应用程序变量这一事实似乎没有太大影响。
http://www.bennadel.com/blog/152-Dynamic-ColdFusion-Variables -Via-Quoted-Naming.htm
I was horsing around and figured it would be nice to move my application variables into a table that can be loaded onApplicationStart.
My intent is to allow ANT to roll out the app, and change a few settings in the database and the proverbial presto..
In my test code, the application.cfc has a simple query to call all the variable names and then a cfloop to set each variable within the application scope as application.varname.
There is no error reported onApplicationStart .. however trying to reference the variables gives an undefined type error.
My spider senses tell me this is something small and obvious... any ideas?
Thanks!!
Update 1 : It seems what I'm looking at is setting dynamic variable names and the fact that they are application variables don't seem to have much impact..
http://www.bennadel.com/blog/152-Dynamic-ColdFusion-Variables-Via-Quoted-Naming.htm
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我不知道作者是在提倡这种语法,还是只是为了证明它的有效性,作为一个兴趣点。
就我个人而言,我更喜欢数组表示法。 我认为这有助于促进良好的范围界定习惯。
I do not know if the author was advocating that syntax or merely demonstrating that it works, as a point of interest.
Personally, I prefer array notation. I think it helps promote good scoping habits.
我的问题的答案是通过引用名称来设置动态变量名称。
更多信息请参见...
http://www.bennadel.com/blog/152-Dynamic-ColdFusion-Variables-Via-Quoted-Naming.htm
The answer to my question was to set dynamic variable names by quoting the names..
More here...
http://www.bennadel.com/blog/152-Dynamic-ColdFusion-Variables-Via-Quoted-Naming.htm
使用 cfloop + cfset 而不是 cfoutput
use cfloop + cfset not cfoutput
如果我正确地阅读您的问题,您是说您正在 cfoutput 标记内设置应用程序变量?
您是否使用 cfoutput 像
您应该使用 cfloop 而不是 cfoutput
不过,如果没有一些代码,则很难提供帮助。
我的问题是:如果您只是要将应用程序变量转储回应用程序范围,为什么要将它们存储在数据库中?
If I'm reading your question correctly, you're saying that you're setting the application variables inside of a cfoutput tag?
Are you using cfoutput like
You should use cfloop rather than cfoutput
It's kind of hard to help without some code though.
My question is: why are you storing your application variables in a database to begin with if you're just going to dump them back into the application scope?