小编Jas*_*son的帖子

使用cfscript查询的查询参数时出错

这是我的代码:

var qryStr = "
            UPDATE templates_email 
            SET title = :title, test_emails = :testEmail, body = :body
            WHERE id = :templateID";

q = New Query();
q.setSQL(qryStr);
q.addParam(name="title", value="#arguments.title#", cfsqltype="cf_sql_char");
q.addParam(name="body", value="#arguments.templateContent#", cfsqltype="cf_sql_char");
q.addParam(name="testEmail", value="#arguments.test_emails#", cfsqltype="cf_sql_char");
q.addParam(name="templateID", value="#arguments.id#", cfsqltype="cf_sql_integer");

return q.execute().getResult();
Run Code Online (Sandbox Code Playgroud)

这是错误:

在指定的参数列表中找不到参数'body WHERE'

SQL:UPDATE templates_email SET title =:title,test_emails =:testEmail,body =:body WHERE id =:templateID

错误发生在C:\ ColdFusion9\CustomTags\com\adobe\coldfusion\query.cfc:第108行

我只能假设我使用参数构建SQL的方式有问题,但无法解决它的问题.谁能看到我在这里做错了什么?

coldfusion

9
推荐指数
2
解决办法
2830
查看次数

ORM EntitySave() - 在调用save()之前必须手动分配此类的ID

当试图做EntitySave("publications",arguments);...我收到以下错误.

ids for this class must be manually assigned before calling save(): publications
Run Code Online (Sandbox Code Playgroud)

我无法理解为什么..我的数据库主键设置正确,我在我的CFC中有setter = false这些属性.我在谷歌搜索时发现了这个错误,但似乎没有任何迹象表明这是导致我的问题的原因.

这是我的CFC.关于我可能做错的任何指示都表示赞赏.谢谢你提前!

Publications.cfc

component persistent="true" table="publications"  
hint="Publications"{
    property name="id" fieldtype="id" setter="false";
    property name="typeid" omrtype="int";
    property name="name" ormtype="string";
    property name="dateScheduled" ormtype="date" ;
    property name="tstamp" ormtype="date";

    property name="Article" fieldtype="one-to-many" cfc="publicationArticles" fkcolumn="publicationid";
}
Run Code Online (Sandbox Code Playgroud)

publicationArticles.cfc

component persistent="true" table="publicationArticles"  
hint="Publications"{
    property name="id" fieldtype="id" setter="false"   ;
    property name="typeid" ormtype="int";
    property name="title" ormtype="string" ;
    property name="status" ormtype="boolean";

    property name="publication" fieldtype="many-to-one" cfc="publications" fkcolumn="publicationid" ;
}
Run Code Online (Sandbox Code Playgroud)

publicationTypes.cfc

   component persistent="true" table="publicationTypes"    
hint="Publicatin Type …
Run Code Online (Sandbox Code Playgroud)

coldfusion coldfusion-9

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

PG :: DatatypeMismatch:错误:列"得分"是整数类型,但表达式是文本类型

这是我的代码:

    factors.each do |f|
      factor_score_var = "factorScore_#{f.id}"
      params['score'] = params[factor_score_var]
      new_scorecard.scorecard_scores.create(params.permit(:score))
    end
Run Code Online (Sandbox Code Playgroud)

这是错误:

PG::DatatypeMismatch: ERROR: column "score" is of type integer but expression is of type text at character 98 HINT: You will need to rewrite or cast the expression.
Run Code Online (Sandbox Code Playgroud)

我尝试使用'to_i'等来投射得分参数.:

params['score'] = params[factor_score_var].to_i
Run Code Online (Sandbox Code Playgroud)

但我只是继续得到同样的错误.

我已经确认:得分是一个数字(如果我手动将var设置为一个数字,我仍然会收到此错误),但我仍然收到此错误.

数据库是Postgress.

任何建议都非常感谢.

贾森

=====================

这是完整的错误消息:

PG::DatatypeMismatch: ERROR: column "score" is of type integer but expression is of type text at character 98 HINT: You will need to rewrite or cast the expression. : INSERT …
Run Code Online (Sandbox Code Playgroud)

postgresql ruby-on-rails ruby-on-rails-4

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

如何在Eclipse中关闭Tab和New Line标记?

我正在使用Adobe的ColdFusion Builder,这是一个基于Eclipse的IDE,构建在Aptana之上.

突然之间,我在Eclipse编辑器中显示了一种空白标记.我一定是不小心撞了一把钥匙.

这是一个屏幕转储.

我看到的标记的屏幕转储

我已经尝试过"常规>编辑器>文本编辑器>显示空白字符"而不是这个. 我已经关闭了显示空格字符.如果我打开它,那么空白字符显示在我已经看到的顶部.

在此输入图像描述

任何人都可以告诉我如何关闭它?最烦人的.

非常感谢

aptana eclipse coldfusionbuilder

6
推荐指数
2
解决办法
5321
查看次数

使用Coldfusion发送大量电子邮件

这个问题可能与做大量的事情有关,但在这种情况下,我正在尝试发送电子邮件.

我已在新线程中设置发送过程,因此用户不会等待,并将请求超时重写为一小时.

问题是,一旦进程发送大约2000封电子邮件(通过以下代码循环约2000次),服务器就会耗尽内存,停止响应并需要重新启动.

阅读其他主题,CF应该能够很好地处理这一批电子邮件.

我考虑过的一件事是将所有对象调用更改为直接数据库查询并使用cfmail标记(我猜)删除所有对象的创建并在达到请求时构建(我猜是正在发生的事情),但我是不确定这是否会产生影响,并且如果可能的话,我真的想避免这种做法.我考虑过的其他东西是将它分成3个或4个单独的线程,但同样,不确定是否能解决问题.

有没有人遇到过这个问题,你发现什么能让处理继续进行而没有ram慢慢填满并杀死服务器?

thread name="sendBroadcastEmail" rc="#rc#" prc="#prc#" filters="#rc.filters#" email="#email#" emailSignature="#emailSignature#"{
    createObject( "java", "coldfusion.tagext.lang.SettingTag" ).setRequestTimeout(javaCast( "double", 3600 ));

        //get profiles that it will be sent to
        var sendToProfiles = profileService.getWithFilters(rc.filters);

        var mailService = getPlugin("MailService");
        var emailSent = false;
        var sentCount = 0;
        var failedCount = 0;

        //send the email (and log in profile events)
        if (listFind(attributes.rc.email.action,'send')){

            for ( i=1; i<=arrayLen(sendToProfiles);i++){
                var profile = sendToProfiles[i];
                try{

                    if (len(trim(profile.getPrimaryEmail()))){

                        var emailBody = profile.processDynamicPlaceholders(attributes.rc.email.body);
                        var emailBody = attributes.emailSignature.getHeader() & emailBody & …
Run Code Online (Sandbox Code Playgroud)

coldfusion coldbox coldfusion-9 coldfusion-10

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

CFC在哪里获得它的应用范围

我有一组CFC,我从两个单独的Applicaiton范围访问.

一个/Application.cfc在Root中.

另一个应用程序位于/Admin/Application.cfc中cfcs位于/ _cfc /中

如果我从(例如)/Admin/members/edit.cfm中的页面调用cfc(使用createObject()),这个cfc是否从以下位置获取它的应用程序范围:

应用程序1:/Application.cfc

要么

应用2:/Admin/Application.cfc

调用页面位于应用程序2下,但CFC本身位于应用程序1下.

我希望我有意义.

谢谢

贾森

coldfusion cfc application.cfc

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

Coldfusion/Java - 获取与服务器不同的时区当前时间

我已经阅读了关于这个主题的每一篇博文,我可以得到我的动手,但却没有获得快乐.

我在澳大利亚珀斯的服务器上运行了一个站点(共享主机,因此服务器时间设置为珀斯时间).但我需要在澳大利亚墨尔本时区记录所有活动.例如,如果将记录写入数据库,我想记录在墨尔本发生的时间,而不是珀斯(例如发布的论坛主题).我不能直接做DateDiff,因为墨尔本有夏令时,而珀斯没有.另外,我想到了这一点,我不妨想出一个可以给我当前墨尔本(或任何地方)时间的方法,无论它运行的服务器的时区如何.

这项任务变成了一个比我预期的要大得多的挑战.

我得到的是这样的:

    timezoneClass = createObject( "java", "java.util.TimeZone" );
    melbourneTimezone = timezoneClass.getTimeZone(javaCast( "string", "Australia/Melbourne" ));
    melbourneCalendar = createObject( "java", "java.util.GregorianCalendar" ).init(melbourneTimezone);
    melbourneTime = melbourneCalendar.getTime();

    writeDump(melbourneTime);
Run Code Online (Sandbox Code Playgroud)

..从我所知道的,这应该给我我需要的东西,但它不会......当我转出'melbourneTime'时,它只给了我服务器时间.

任何人都可以给我任何指示.我是在正确的道路上,还是一种更简单的方法来实现预期的结果.

非常感谢

贾森

java coldfusion

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

使用Coldfusion Orm存储货币

我需要在存储货币(美元和美分)的CF Orm实体中创建一个属性.例如:100.99或1.30等我传统上使用十进制来存储货币,因为你可以得到小数点,但没有小数的ORM属性类型,只有浮点数.我尝试设置scale = 2,但是(例如)1.30存储为1.3,或5.00存储为5.

任何人都可以使用CF ORM建议使用货币(有两位小数)的最佳方式吗?

非常感谢

coldfusion orm cfml

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

如何判断coldfusion查询是否缓存?

我已经在一个运行很多次的查询上设置了缓存..查询本身并不是那么慢,但每次请求都会运行多次,因此有点缓存可能有所帮助.我已经启用了缓存,但似乎没有什么区别......如何判断我的查询是否被缓存?

我正在设置缓存: q.setCachedWithin("#createTimespan(0, 1, 0, 0)#");

这是我的完整查询准备:

            q = New Query();
            q.setSQL("SELECT * FROM guest_booking WHERE room_id = :roomID and check_in <= :iDate and check_out > :iDate and status != 0");
            q.setName("checkAvailability");
            q.setCachedWithin("#createTimespan(0, 1, 0, 0)#");
            q.addParam(name="iDate", value="#createODBCDate(arguments.date)#", cfsqltype="cf_sql_date");
            q.addParam(name="roomID", value="#createODBCDate(arguments.room_id)#", cfsqltype="cf_sql_integer");
            qResult = q.execute().getresult();
Run Code Online (Sandbox Code Playgroud)

调试输出显示:

checkAvailability (Datasource=accom_crm, Time=16ms, Records=1) in C:\ColdFusion9\CustomTags\com\adobe\coldfusion\base.cfc @ 16:15:56.056


                        SELECT * FROM guest_booking WHERE room_id = 

                                    ?

                                 and check_in <= 

                                    ?

                                 and check_out > 

                                    ?

                                 and status != 0

Query Parameter Value(s) -
Parameter #1(cf_sql_integer) …
Run Code Online (Sandbox Code Playgroud)

coldfusion

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

在Where子句中选择带MAX()聚合的语句

我有一个数据库表,每年都会存储会员续订.插入续订记录时,"expiryDate"列将写入日期(31/8/[nextyear]).

因此,作为一个例子,假设一个成员在2007,2008和2009年更新了memberID = 99,他将有3条记录(每年一条记录),每条记录中都记录了"expiryDate".如果我做了

SELECT MAX(YEAR(expiryDate)) as maxExpiry 
  FROM renewals 
 WHERE memberID = 99
Run Code Online (Sandbox Code Playgroud)

......我将回归2010年.

我想做的是返回MAX(YEAR(expiryDate))给定年份的所有记录...例如,

SELECT * 
  FROM renewals 
 WHERE MAX(YEAR(expiryDate)) = '2010';
Run Code Online (Sandbox Code Playgroud)

这个查询不起作用,因为聚合不能在子查询之外的where子句中使用,但我无法弄清楚如何构造子查询...或者即使这样做可以比使用更好的方式一个子查询.

sql sql-server aggregate-functions

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