Can someone look over this simplified example and tell me if this is the best practice for doing a standard query using components?

I'm particularly fretting over Variables.DSN.

I'm totally open to changes, no worries about hurting my feelings.

 

 

 

myForm.cfm contains:

 

<cfset myObj = CreateObject("Component","Components.myComponent")>

<cfset Temp = myObj.Init(Application.DSN)>

<cfset myQry = myObj.myFunction(ID)>

 

<body>

<cfdump var="myQry">

</body>

</html>

 

 

MyComponent.cfc contains:

 

<cfcomponent output="False">

 

<cffunction name="Init" output="False" returntype="void">

<cfargument name="DSN" required="yes">

<cfset Variables.DSN = arguments.DSN>

</cffunction>

 

<cffunction name="myFunction" output="False" returntype="query">

                <cfargument name="ID" type="numeric">

                <cfset var result = "">

                <cfquery name="result" datasource="#Variables.DSN#">

                SELECT * FROM myTable WHERE myTableID = #arguments.myTableID#

                </cfquery>

                <cfreturn result>

</cffunction>

 

</cfcomponent>

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).

An archive of the CFCDev list is available at www.mail-archive.com/[email protected]

Reply via email to