Sorting on Column in Type Table with ColdFusion ORM

后端 未结 1 1882
野性不改
野性不改 2021-01-11 09:54

I have three tables, with the following structure:

http://dl.dropbox.com/u/2586403/ORMIssues/TableLayout.png

The three objects I\'m dealing with are here:

相关标签:
1条回答
  • 2021-01-11 10:08

    I solved this one with Sam's help, by setting up a method in my Service that returned the items in the order I wanted. I just used ORMExecuteQuery to get the items in the right order, and if there were no items, just returned an empty array.

    The final method looked like this, where specifications are set directly in the object in the order I want them:

    /**
    @hint Gets a SpecGroups object based on ID. Pass 0 to retrieve a new empty SpecGroups object
    @ID the numeric ID of the SpecGroups to return
    @roles Admin, User
    */
    remote ORM.SpecGroups function getSpecGroup(required numeric ID){
        if(Arguments.ID EQ 0){
            return New ORM.SpecGroups();
        }else{
            LOCAL.SpecGroup = EntityLoadByPK("SpecGroups", Arguments.ID);
            LOCAL.SpecsInGroup = ORMExecuteQuery("SELECT Spec FROM SpecInGroup G WHERE G.SpecGroupID = :GroupID ORDER BY SpecLabel, SpecName", {GroupID = LOCAL.SpecGroup.getID()});
            LOCAL.SpecGroup.setSpecifications(LOCAL.SpecsInGroup);
            return LOCAL.SpecGroup;
        }
    }
    
    0 讨论(0)
提交回复
热议问题