开发者

Using ColdFusion 9's ORM, how do you create a property that converts a database string into a boolean value?

I'm working with a legacy database that stores a boolean column as a string, where true is "Y" and false is an empty string. How would I map a property so that it's able to convert this value to an actual boolean, but still save to the database as "Y" and empty 开发者_运维知识库string, for legacy purposes?


I would take care of this with custom getters and setters. Just create your own getProperty and setProperty methods that will convert the value both directions. I don't know that there's any other way to programatically change the meaning of a value directly through the property mappings.

function setProperty(value){
    if(Arguments.Value){
        this.Property = "Y";
    }else{
        this.Property = "";
    }
}

function getProeprty(){
     return (this.Property EQ "Y");
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜