我有一個模型,surveyTemplate
,它只有一個屬性由查詢填充。爲什麼我可以在嵌入對象的查詢中引用RecordCount,但是我無法遍歷它?
我在模型的最後一個屬性surveyTemplateQuestions
中存儲了一個額外的查詢。
如果我做到以下幾點:
writeDump(var="#surveyTemplateObj#"); abort;
我得到正確填入包含查詢數據的最後一個屬性的模型。
我也可以這樣做:
writeDump(var="#surveyTemplateObj.getSurveyTemplateQuestions()#"); abort;
現在我得到的只是存儲在模型的最後一個屬性的查詢。
那麼,爲什麼我不能做到這一點:
<cfoutput query="prc.surveyTemplateObj.getSurveyTemplateQuestions()">
在做上面我收到以下錯誤:
The value of the attribute query, which is currently prc.surveyTemplateObj.getSurveyTemplateQuestions(), is invalid.
但我能做到這一點,而不是:
<cfloop from="1" to="#prc.surveyTemplateObj.getSurveyTemplateQuestions().RecordCount#" index="i">
怎麼可能當我做一個cfdump
對象的最後一個屬性顯示爲查詢,我可以做一個RecordCount
對查詢對象,但我不能循環查詢對象通過cfoutput
?
只是爲了澄清,如果你看看[的文檔(https://helpx.adobe.com/coldfusion/cfml-reference/ coldfusion-tags/tags-mo/cfoutput.html),它表示它期望查詢的*名稱*,即字符串,而不是查詢*對象*或類似返回查詢對象的函數。 – Leigh