我使用的一种常见设计是将当前日期设置为默认日期列。对于SQL Server,我使用getDate(),对于MySQL now,我使用current_timestamp。
在ORM中实现MySQL解决方案,似乎是这样做的:
property name="dtSaved" ormtype="date" dbdefault="now()";但是,这不起作用,但也没有抛出错误。当我运行ORMReload()时,它似乎卡在这个表上,后面的实体(按字母顺序)都没有被创建。(我使用dbcreate="dropcreate")
请注意,这是Railo3.3.1,不是ColdFusion 9。
发布于 2012-02-17 23:32:10
您可以在构造函数中设置动态默认值,如下所示:
component persistent="true" {
property name="measurementDate" ormtype="date";
function any init(){
if (IsNull(variables.measurementDate)){
variables.measurementDate = Now();
}
return this;
}
}John Whish评论- 2010年11月22日
来自:http://www.aliaspooryorik.com/blog/index.cfm/e/posts.details/post/coldfusion-9-orm-example-215
https://stackoverflow.com/questions/9073516
复制相似问题