是否可以动态调用 cfquery 变量?
我正在执行一个查询,其中有 12 个名为“choice_1”到“choice_12”的条目。我希望能够根据循环中的位置动态调用单个选择。 所以这里是查询:
<CFQUERY DATASOURCE="tr3" NAME="qryUserMatchPref">
SELECT *
FROM UsrMatchPrefTR2
WHERE session = #sess# AND site = #siteFirst# AND user_id = #tempUser#
</CFQUERY>
假设循环正在第三次运行,我想检查 choice_3,理论上我想做这样的事情。
<cfset combined = "choice_" & counterChoice>
<cfset tempMatch = qryUserMatchPref.#combined#>
如果 counterChoice 等于 3,我当然会查询 choice_3,而不是查询“组合”列中的内容 [在本例中不存在]。有没有办法在 Coldfusion 中做到这一点,或者我注定要创建一系列非常乏味的 if 语句? d:
I'm going through a query in which there are 12 entries named "choice_1" through "choice_12." I want to be able to dynamically call an individual choice depending where it is in the loop.
So here is the query:
<CFQUERY DATASOURCE="tr3" NAME="qryUserMatchPref">
SELECT *
FROM UsrMatchPrefTR2
WHERE session = #sess# AND site = #siteFirst# AND user_id = #tempUser#
</CFQUERY>
And let's say the loop is on it's third run and I wanted to check choice_3, I would want in theory to do something like this.
<cfset combined = "choice_" & counterChoice>
<cfset tempMatch = qryUserMatchPref.#combined#>
I would of course be querying for choice_3, if counterChoice is equal to 3, and not for what ever is in the "combined" column [doesn't exist in this case]. Is there a way to do this in coldfusion or am I doomed to create a very tedious series of if statements? D:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你应该能够做到
you should just be able to do