문제

In my CFCs, I have lists of DB fields that will be used in the SELECT statement inside of a cfquery

<cfcomponent>

<cfscript>
...

variables.lstNode = "NodeID,ParentNodeID,Root,Kind
  ,extra,Slug,title,subtitle,description,isbn,parenttitle,ParentCreateDate
  ,strData,xmlData,pinned,pStatus,cStatus
 ...

later in many many place I do things like

    <cfquery name="qryData">
        SELECT  #variables.lstNode# 
        FROM    dbo.vwNode WITH (NOLOCK)

What other approaches are there to this concern. Note ORM is not an option

도움이 되었습니까?

해결책

I have historically used cfproperty at the top of a CFC to define the database columns, and that just happens to be the way that ORM does it too. It is tidy, and it has the advantage that you could specify other attributes such as the datatype. If you plan to write standard methods for searching and editing your records, then it could be a good approach. Otherwise, it's probably needlessly complicated.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top