标签: cfml

如何计算列总和

我之前问过这样的问题,但没有得到任何好的答案,可能是因为代码太长或我的问题不清楚.这个时候我会尽我所能:)到目前为止,我已经编写了代码来从表中查找行和,这很好:

<cfloop list="#product_id_list#" index="product_index">
    <cfloop list="#month_list#" index="month_index">
        <cfoutput query="GET_SALES_TOTAL">
            <cfif AY eq month_index and product_id eq product_index>
                <cfloop list="#type_index#" index="tt_index">
                    <cfset 'alan_#tt_index#_#month_index#_#product_index#' = evaluate(tt_index)>
                </cfloop>
            </cfif>
        </cfoutput>
    </cfloop>
</cfloop>
<cfset 'total_#ii_index#_#p_index#'=evaluate('total_#ii_index#_#p_index#') + #evaluate('alan_#ii_index#_#ddd_other#_#p_index#')#>
Run Code Online (Sandbox Code Playgroud)

现在我想找一个列总和.列总和的代码有效,但不正确.它计算最后一个产品的总和:

<cfloop list="#product_id_list#" index="product_index">
    <cfloop list="#month_list#" index="month_index">
        <cfoutput query="GET_SALES_TOTAL">
            <cfif AY eq month_index and product_id eq product_index>
                <cfloop list="#type_index#" index="tt_index">
                    <cfset 'alan2_#tt_index#_#month_index#_#product_index#' = evaluate(tt_index)>
                </cfloop>
            </cfif>
        </cfoutput>
    </cfloop>
</cfloop>
<cfset 'total2_#ddd_other#_#p_index#'=evaluate('total2_#ddd_other#_#p_index#') + #evaluate('alan2_#ii_index#_#ddd_other#_#p_index#')#>
Run Code Online (Sandbox Code Playgroud)

行和的输出:

<cfloop list="#product_id_list#" index="p_index">
    <cfloop list="#type_index#" index="kk_ind">
        <td align="center">
          <font color="##FF0000">#TLFormat(evaluate('total_#kk_ind#_#p_index#'),0)#</font>
        </td> 
    </cfloop>
</cfloop> …
Run Code Online (Sandbox Code Playgroud)

coldfusion row sum cfml

1
推荐指数
1
解决办法
5586
查看次数

将mysql_connect转换为cfquery

什么相当于coldfusion中的代码.我可以用php连接到数据库但是在正确设置cfquery标签时遇到了麻烦

mysql_connect("your.hostaddress.com", "username", "password") or die(mysql_error());
mysql_select_db("Database_Name") or die(mysql_error()); 
$data = mysql_query("SELECT * FROM friends") 
or die(mysql_error());
Run Code Online (Sandbox Code Playgroud)

php mysql cfml

1
推荐指数
1
解决办法
159
查看次数

ColdFusion表单中的复选框

我的代码如下.我需要在页面加载时默认选中两个复选框.这将显示查询结果.现在,当取消选中其中一个复选框时,需要提交表单,并且需要显示不同的查询结果.即使取消选中复选框,也始终会检查复选框.有人可以在这里指导我吗?

<form action="abc.cfm?show=yes" method="post" name="myform">
    <table align="center">
    <tr>
        <td>
            <input type="checkbox" checked="checked" name="chkbox" id="chkbox1"> <strong> Agreement Only</strong> 
            &nbsp;&nbsp;<input type="hidden" name="chk" id="chk1">
            <input type="checkbox" checked="checked" name="chkbox" id="chkbox2"> <strong>Active Employees</strong> 
            &nbsp;&nbsp;<input type="hidden" name="chk" id="chk2">
        </td>
        <td>
            <input type="Submit" name="submitnow" value="View now">
        </td>
    </table>
</form>

<cfif isdefined("form.chk1")>
    query 1
<cfelseif isdefined("form.chk2")>
    query 2
</cfif>
Run Code Online (Sandbox Code Playgroud)

javascript coldfusion cfml

1
推荐指数
1
解决办法
5109
查看次数

cfInclude没有cfoutput标签

好吧,我有模板文件,我知道它们需要在<cfoutput>标签之间,但是在一个<cfoutput>标签周围放置一个标签<cfinclude>将无法正常工作,并且任何具有不起作用的标签文件都<cfmodule>不允许我操作variables范围.

那么,任何想法 - 无论多么复杂 - 哪些都可以让我包含这样一个模板文件并让它像<cfoutput>标签之间那样表现?


上下文:这是我正在研究的"框架"并要求每个模板文件以<cfoutput>标签开始和结束似乎是一种真正的浪费,特别是因为模板文件看起来越少'冷混合',IMO越好.

coldfusion openbd cfml

1
推荐指数
1
解决办法
607
查看次数

如何确认cffile写入成功?

我正在使用cffile创建新文件或更新现有文件,具体取决于用户请求的内容.请求来自前一个过程的表单,因此涉及cffile的代码如下所示:

<cfset thefile = "#form.dyn#">
<cfoutput>
<cfsavecontent variable = "testvar">
  #form.editor1#
</cfsavecontent>     
<cffile action = "write"
    file   = "/var/www/reports/#thefile#.cfm"
    output = "#testvar#">
</cfoutput>
Run Code Online (Sandbox Code Playgroud)

当我写完文件后,我想向用户确认发生这种情况.对于一个新文件,我可以使用IsDefined来检查它是否存在.但我想不出一种方法来检查已更新的现有文件.我考虑过cffile上的try/catch,但只有在看上去没有出错的情况下,catch才会运行.如果我没有收到错误,我可以假设一切都好吗?如果可能的话,我更愿意直接检查.有没有人有想法?

coldfusion cffile cfml

1
推荐指数
2
解决办法
785
查看次数

CFML if/else语句在Coldfusion 6下表现得很奇怪

我有以下非常简单的if/else语句:

<cfif Server.ColdFusion.ProductVersion GTE "7">
        <cfoutput>#encrypt("Test text", "77qidrWFoQg96taobooCm3/WimS2Gcdd", "DESEDE", "Hex")#</cfoutput>
<cfelse>
        <cfoutput>#encrypt("Test text", "77qidrWFoQg96taobooCm3/WimS2Gcdd")#</cfoutput>
</cfif>
Run Code Online (Sandbox Code Playgroud)

它应该在CF 7,8,9,10之下,但不在CF 6之下,我得到以下错误,因为它不关心<cfif>标签并执行对更高版本的CF(> 7)的意义.

在此输入图像描述

任何的想法?我尝试了许多不同的ion和相同的结果.CF 6让我绝望.PS不,我的客户我写的一些脚本不会转移到更高版本.

coldfusion cfml

1
推荐指数
1
解决办法
472
查看次数

在Coldfusion中,您如何按字母顺序排序列表,然后按数字顺序排序

说我有以下列表:

<cfset myList = "1a,2b,3c,aa,bb,cc" >
Run Code Online (Sandbox Code Playgroud)

如何对此列表进行排序,使其成为"aa,bb,cc,1a,2b,3c"?换句话说,我希望以数字开头的任何内容都位于列表的末尾,并按照它开头的数字顺序排列.

coldfusion coldfusion-9 cfml

1
推荐指数
1
解决办法
970
查看次数

在ColdFusion查询中联接表

我正在执行两个查询,以根据同一数据库中两个表的数据构建一个表。我现在的代码在下面,但是我知道我正在以这种方式创建不必要的负载。我一直在尝试加入表格以得到相同的结果,但是没有运气。有输入吗?

<cfquery name="GetWeekends">
   SELECT id, weekend_type, community_id, start_date, end_date, language
   FROM _weekends
   WHERE weekend_type = 1 and start_date > Now()
   ORDER BY start_date ASC
</cfquery>  

<cfloop query="GetWeekends">                
    <cfquery name="GetCommunity">
        SELECT community_id, location, language, state, country
        FROM _communities
        WHERE community_id = #getweekends.community_id#
    </cfquery>                  
    <tr>
        <td>#DateFormat(start_date, "mm/dd/yyyy")#</td>
        <td>#GetComm.location#</td>
        <td>#GetComm.state#</td>
        <td>#GetComm.country#</td>
        <td>#GetComm.language#</td>
   </tr>
</cfloop>
Run Code Online (Sandbox Code Playgroud)

mysql coldfusion railo cfml lucee

1
推荐指数
1
解决办法
411
查看次数

在cfscript ColdFusion中定义变量?

我尝试用我的系统重写我Application.cfc和其他.cfc文件cfscript.我不确定它们在cfscript中是如何工作的.我想知道在函数内部定义变量.例如,onRequestStart()函数看起来像这样:

function onRequestStart(required string thePage) returntype="boolean" output="false" {
        var request.appCode = "MyApp";
        var request.appName = "Single Page Application";
        var page = listLast(arguments.thePage,"/");
        var onApplicationStart();

        if(!listFindNoCase("Home.cfm,Auth.cfc",page)){
            if(structKeyExists(SESSION, "loggedin") AND SESSION.loggedin EQ false){
                location(url="https://www.myapp.org", addToken="false");
            }
        }

        return true;
    }
Run Code Online (Sandbox Code Playgroud)

var在我定义request/session变量的情况下,我是否需要使用单词?如果我做什么是最佳做法,请使用var word或use local.variablenamelocal和是variables一样的cfscript吗?

variables coldfusion cfml coldfusion-2016

1
推荐指数
1
解决办法
1082
查看次数

可以在cfscript中创建&lt;cfxml&gt;吗?

有没有办法在cfscript中使用?我在网上找不到一个简单的例子。我有一个使用cfscript构建的.cfc文件,并且正在尝试使用cfxml。

我有一个XMLContent变量,并且尝试了下面的代码。

cfxml variable="myXML" {
    WriteOutPut(#XMLContent#);
}
Run Code Online (Sandbox Code Playgroud)

它正在返回:function keyword is missing in FUNCTION declaration.在我的cfxml声明中。

coldfusion xml-parsing cfml

1
推荐指数
1
解决办法
44
查看次数