Coding convention/best practice question here.

In my component, I've got GetOneRecord and GetAllRecords functions. Is it best 
to combine those functions and use some CFIF logic around a WHERE statement, or 
should I keep them separate? 

Here's the combined code:

<cffunction name="getRecords" access="public" returntype="query" hint="Get one 
record if recordID is passed, or get all records." output="false">
                
   <cfargument name="recordID" type="numeric" required="no" />
                
   <cfquery name="getRecords" datasource="#DSN#">
      SELECT *
      FROM table
      <cfif isDefined("arguments.recordID")>
          WHERE recordID = <cfqueryparam value="#arguments.recordID#" 
cfsqltype="cf_sql_integer" />
      </cfif>
      ORDER BY recordName
   </cfquery>
                
   <cfreturn getRecords />
</cffunction>

Thoughts, anyone?

Thanks,
Cameron

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:237140
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to