0

这是场景,我从以下代码获取结果集,并在从 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#">

编辑

下面的截图

在此处输入图像描述

4

2 回答 2

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>

另见

查询聚合函数的查询支持

http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec0e4fd-7ff0.html#WSc3ff6d0ea77859461172e0811cbec0e4fd-7fcc

于 2014-03-16T05:52:22.557 回答
0

复制结构

首先关闭

<cfset answers = initial.getSearchResults('#URL#')>

不会工作。如果我们忽略这个的危险,你可以

<cfset answers = initial.getSearchResults(URL)>

<cfdump>无法在 a 内生成任何输出<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>
于 2014-03-15T19:20:33.643 回答