- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我在尝试在 CfWheels 的 findAll() 方法的 where 子句中使用 SQL 函数时遇到问题。
<cfset currencyInfo= model('pricelist').findAll(select="currencyid,name",where="YEAR(startDate)=#params.year#")>
这里令人困惑的是,在同一条语句的 select 子句中使用 sql 函数时,它的工作原理很神奇。
<cfset currencyInfoTest= model('pricelist').findAll(select="currencyid,name,YEAR(startDate) AS Year",where="id=5")>
我猜 CFWheels 可能只处理 select 子句中的列映射,而不处理 where 子句中的任何计算或操作语法。
我需要在上面的 where 子句中使用一些 sql 函数。有什么想法吗?
最佳答案
您的假设是正确的,即 CFWheels 不允许 where
中的 SQL 函数争论。它解析属性名称的字符串,以便将它们映射到数据库中的列,并且它还应用 <cfqueryparam>
绑定(bind)到传入的值。但它无法解析对 SQL 函数的调用。
但是,您可以创建 calculated property基于您需要的 SQL 函数并对其进行查询。
在models/PriceList.cfc
:
function init() {
property(name="startDateYear", sql="YEAR(pricelists.startdate)";
}
在你的findAll
调用:
currencyInfo = model('pricelist').findAll(select="currencyid,name", where="startDateYear=#params.year#");
关于mysql - CFWheels:在 WHERE 子句中使用 SQL 函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21250850/
根据我对 chwheels 的一些了解,我知道路线存储在应用程序范围内,即准确地说在 application.wheels.routes 中。它还在 application.wheels.namedr
我有一个新模型 myModel,我正在创建它,它与正在创建的一堆子模型 mySubModel 具有一对多关系同时。 当我尝试保存模型时: 仅保存模型部分,不创建 params.myModel.my
我正在尝试获得更好的设置来更新具有嵌套属性的模型。 现在在我的编辑 View 中,我手动定义 textFieldTag 以通过将名称设置为 "myModel[myNestedProperty][#mo
我之前遇到过插件问题,但结果证明是我的主机“Hostek”出现了故障。好吧,我想,我将设置本地 Railo/Tomcat 环境并在本地工作。 一切正常......除了插件......再次! 无论我做什
我需要有关研究以下问题的建议。 Wheels 网站配置了 set(URLRewriting="On"),除根页面外一切正常。 所有使用 linkTo 构建的链接看起来都像 website.tld/co
CFWheels 有 URLFor()用于根据提供的参数获取内部 URL 的函数。有没有办法在不提供任何参数的情况下获取内部 URL? 例如:如果用户导航到“http://somedomain.com
对执行重定向的 Controller 操作进行单元测试的正确方法是什么? 更新:我是 CFWheels 项目的核心开发人员。我问这个问题的全部原因是目前我正在努力增强我们拥有的内置测试框架,我想知道如
假设我有一个非常简单的 Controller ,如下所示: 在直接的 ColdFusion/Railo 中,我会在本地限定所有变量的范围……但我看到的每个轮子
我在使用 CFWheels 的 Railo 上使用 save() 时出现以下错误: Cannot execute statement: impossible to write to binary lo
我在 Amazon EC2 Windows 实例上运行 CFWheels、Railo。每隔几天,tomcat 的服务就会停止工作,我必须重新启动它。它没有给我任何错误,它只是显示“服务不可用”。 关于
出于某种原因,当我在 findAll() 的顺序子句中指定“随机”时,CFWHeels 抛出错误: Wheels.ColumnNotFound Wheels looked for the column
(这里是轮子新手) 我正在尝试找出放置 View Controller 函数中使用的大量大型和/或复杂查询的最佳位置。 我有一个观点 calendar.cfm ,以及具有以下功能的 Controlle
我有一个查询返回 , 中的名称格式如 SELECT instructor_DBID, last_name + ', ' + first_name as instruc
我在尝试在 CfWheels 的 findAll() 方法的 where 子句中使用 SQL 函数时遇到问题。 这里令人困惑的是,在同一条语句的 select 子句中使用 sql 函数时,它的工作原
如何配置 CFWheels 以在 http://mydomain.com/sitemap.xml 处显示以下 XML ? tags dynamically here later --
我在 MySQL 的表中添加了几列: totalSavings DOUBLE NOT NULL DEFAULT 0 totalDebt DOUBLE NOT NULL DEFAULT 0 表格中还有其
cfform 中有一个名为preserveData 的属性,用于在表单提交后保留各种控件的值。 在 cfwheels 的 startFormTag() 中是否有任何属性可以实现相同的功能。 如果没有,
我有一个过滤器设置,它运行一个函数来检查用户 session 是否存在于某些操作中,就像这样; 问题是,这些是 Action 名称……与我拥有的其他 Controller
这更像是一个操作方法,而不是一个实际问题。 (我搜索并没有找到解决方案,所以我想出了这个) 我需要创建一个 Excel 文件导出,允许用户: 使用表单从原始表中过滤数据 将结果从原始表导出到 Exce
我似乎不知道如何在 CFWheels 中创建页面使用包含"file"扩展名的干净 URL。 我希望能够做到以下几点: http://www.example.com/products.xml http:
我是一名优秀的程序员,十分优秀!