Frage

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

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top