本文介绍了我可以在 ColdFusion 中按索引获取查询行吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在 ColdFusion Query 对象中获取特定行而不循环它.
I want to get a specific row in a ColdFusion Query object without looping over it.
我想做这样的事情:
<cfquery name="QueryName" datasource="ds">
SELECT *
FROM tablename
</cfquery>
<cfset x = QueryName[5]>
但它给了我一个错误,说查询不能被5"索引.我知道这个查询中有超过 5 条记录.
But it's giving me an error saying that the query isn't indexable by "5". I know for a fact that there are more than 5 records in this query.
推荐答案
CF <= 10 无法获取行,必须获取特定列.
You can't get a row in CF <= 10. You have to get a specific column.
<cfset x = QueryName.columnName[5]>
然而,自从我发布这个答案已经 8 年了.显然 CF11 终于实现了这个功能.请参阅 呃 StackExchange 的回答.
It's been 8 years since I posted this answer, however. Apparently CF11 finally implemented that feature. See ugh StackExchange's answer.
这篇关于我可以在 ColdFusion 中按索引获取查询行吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!