ColdFusion 9 ORM CFGird连接几个表

时间:2011-05-10 15:00:49

标签: orm coldfusion coldfusion-9 cfgrid

当使用ColdFusion ORM,你有多个表有关系时,我可以将CFC绑定到CFGrid以获取我想要显示的所有列吗?

示例如果我在当前应用程序上有7个连接的查询我正在处理以获取我想要显示的所有字段。如何在CFGrid中显示所有字段?我可以使用bind将ORM CFC连接到网格吗?或者我需要做别的事吗?

SELECT 'PRIMARY' AS TMSType,
  'Request'      AS shopTypeTitle,
  rfc_shopsheet.shopsheetid,
  locked,
  isDraft,
  shoptype,
  rfc_shopsheet.createdon,
  FacilitatorCompleted,
  Details.myshopfolderid   AS RecordId,
  Details.subject          AS ShopSubject,
  Details.solostandmodelid AS DisplayModelid,
  ShopVACM.solostandmodel  AS DisplayModel,
  Details.myshoplevelid,
  Details.divisionid,
  val_myshoplevel.name,
  divisionname,
  GROUP_CONCAT_solostandSERIES(rfc_shopsheet.shopsheetid) AS Series,
  MAX(RequestDTGs.sortdate)                               AS RSortDate,
  MAX(RequestDTGs.sortsequence)                           AS RSeq,
  rfc_shopsheet.CreatedOn                                 AS holdshopCreateDate,
  Details.AIRSNbr
FROM rfc_shopsheet
JOIN rfc_myshopfolder Details
ON rfc_shopsheet.myshopFolderId = Details.myshopFolderId
LEFT OUTER JOIN rfc_shopsigner
ON rfc_shopsheet.shopsheetid = rfc_shopsigner.shopsheetid
LEFT OUTER JOIN rfc_requestdtg RequestDTGs
ON RequestDTGs.myshopfolderid = Details.myshopfolderid
LEFT OUTER JOIN rfc_engshop
ON rfc_shopsheet.shopsheetid = rfc_engshop.shopsheetid
LEFT OUTER JOIN rfc_requestaircraft RequestAC
ON Details.myshopfolderid = RequestAC.myshopfolderid
LEFT OUTER JOIN rfc_requestfacilitator RequestFac
ON Details.myshopfolderid = RequestFac.myshopfolderid
LEFT OUTER JOIN val_solostandseries shopVAC
ON RequestAC.solostandseriesid = shopVAC.solostandseriesid
LEFT OUTER JOIN val_solostandmodel shopVACM
ON Details.solostandmodelid = shopVACM.solostandmodelid
LEFT OUTER JOIN val_myshoplevel
ON Details.myshoplevelid = val_myshoplevel.myshoplevelid
LEFT OUTER JOIN val_division
ON Details.divisionid = val_division.divisionid
WHERE shopType        = 'F'

我想找到一种方法让ORM加入所有这些列,这样我就可以把它们放在ORM中。

2 个答案:

答案 0 :(得分:0)

无论您是否使用ORM,

<cfgrid>都不会小心谨慎。

所以只需使用<cfquery>进行连接,然后使用远程函数中的QueryConvertForGrid()返回结果。如果您没有使用绑定,则只需使用实际查询提供<cfgrid>

答案 1 :(得分:0)

据我所知,你还没有建立任何ORM实体? (每张表的CFC)

如果还没有,您只需设置所有表(使用带有RDS连接的cfbuilder来构建您的ORM CFC文件)

在ORM Persisted CFC文件中引用所有表后,可以使用cfquery标记和dbtype =“HQL”执行此操作,并使用QueryConvertForGrid()返回数据

然后只需通过json将您想要的数据返回到cfgrid,或直接在页面上返回cfgrid标记。