|
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] |
- RE: [CFCDev] Free vs. Paid Training for CF frameworks W... Sean Stickle
- Re: [CFCDev] Free vs. Paid Training for CF framewo... Sean Corfield
- RE: [CFCDev] Free vs. Paid Training for CF framewo... Sean Stickle
- Re: [CFCDev] Free vs. Paid Training for CF fra... Sean Corfield
- Re: [CFCDev] Free vs. Paid Training for CF... Matt Woodward
- RE: [CFCDev] Free vs. Paid Training for CF framewo... John Farrar
- Re: [CFCDev] Free vs. Paid Training for CF framewo... Barry Beattie
- RE: [CFCDev] Free vs. Paid Training for CF framewo... Hal Helms
- RE: [CFCDev] Free vs. Paid Training for CF framewo... Hal Helms
- Re: [CFCDev] Free vs. Paid Training for CF framewo... M@ Bourke
- [CFCDev] Syntax Phillip Senn
- Re: [CFCDev] Syntax Matt Woodward
- [CFCDev] Syntax take 2 Phillip Senn
- RE: [CFCDev] Syntax take 2 Phillip Senn
- Re: [CFCDev] Syntax Seth Petry-Johnson
- Re: [CFCDev] Syntax Jason Daiger
