这是方案,我从以下代码获取结果集,并且在从cfdump获取结果后运行以下查询,但它显示空的第二次转储,不是为什么?
任何人都可以检查出错:
<cfif StructKeyExists(URL,'submitsearch') AND URL.submitsearch neq ''>
<cfset answers = initial.getSearchResults('#URL#')>
<cfset flag = 'yes'>
</cfif>
<cfchart format="png" scalefrom="0" scaleto="#answers.recordcount#" show3d="Yes">
<cfchartseries type="bar" serieslabel="Support Tickets" seriescolor="##009933">
<cfdump var="#answers#">
<cfoutput query="answers">
<cfquery dbtype="query" name="myString">
SELECT count(*) as strvalue
FROM answers
WHERE status = "#trim(answers.status)#"
</cfquery>
<cfchartdata item="#Status#" value="#myString.strvalue#">
</cfoutput>
<cfdump var="#myString#">
</cfchartseries>
</cfchart>
这是一个问题,它什么都没有:不知道为什么:
<cfdump var="#myString#">
修改
下面的截图
答案 0 :(得分:1)
根据提供的屏幕截图,建议如下
<cfif StructKeyExists(URL,'submitsearch') AND URL.submitsearch neq ''>
<cfset answers = initial.getSearchResults(URL)>
<cfset flag = 'yes'>
</cfif>
<cfquery dbtype="query" name="qrySummary">
SELECT status, count(status) as strvalue
FROM answers
GROUP BY status
ORDER BY status
</cfquery>
<cfdump var="#qrySummary#">
<cfchart format="png" scalefrom="0" scaleto="#answers.recordcount#" show3d="Yes">
<cfchartseries type="bar" serieslabel="Support Tickets" seriescolor="##009933">
<cfoutput query="qrySummary">
<cfchartdata item="#Status#" value="#strvalue#">
</cfoutput>
</cfchartseries>
</cfchart>
另见
查询对聚合函数的查询支持
答案 1 :(得分:0)
复制结构
首先关闭
<cfset answers = initial.getSearchResults('#URL#')>
不行。如果我们忽略这个危险,你可以
<cfset answers = initial.getSearchResults(URL)>
<cfdump>
无法在<cfchart>
内生成任何输出。如果你想要转储,它必须在图表之外。要调试数据,请考虑使用以下内容:
<cfdump var="#answers#">
<cfoutput query="answers">
<cfquery dbtype="query" name="myString">
SELECT count(*) as strvalue
FROM answers
WHERE status = <cfqueryparam value = "trim(answers.status)#" cfsqltype = "cf_sql_varchar">
</cfquery>
#myString.strvalue#
</cfoutput>
<cfdump var="#myString#">
还要考虑更改代码,以便您没有内部查询。您将获得更好的性能,并且更容易调试。
<强>更新强>
<cfdump var="#answers#">
<!--- at this point, confirm that you are returning a query --->
<cfoutput query="answers">
<cfquery dbtype="query" name="myString">
SELECT count(status) as strvalue
FROM answers
WHERE status = <cfqueryparam value = "trim(answers.status)#" cfsqltype = "cf_sql_varchar">
</cfquery>
<!--- here you should have a series of queries with one row, one column --->
<cfdump var="#myString#">
</cfoutput>