Why the "my" in "variables.my.dsn"? What's the advantage over "variables.dsn"?
Thanks,
Steve
At 03:08 AM 9/9/2005, Barney Boisvert wrote:
You've got it. Though I'd recommend the constructor, that's what it's
there for. No real need to have get/set methods; how often do you
change datasources without reloading your application? Easier to just
set it as an immutable property at instantiation time and forget about
it. And don't forget to scope your query name. Here's how I do it
(with lot of tag attributes missing for brevity):
<cfcomponent>
<cffunction name="init">
<cfargument name="dsn" />
<cfset variables.my.dsn = dsn />
<cfreturn this />
</cffunction>
<cffunction name="getEmployees">
<cfset var getEmployees = "" />
<cfquery datasource="#variables.my.dsn#" name="getEmployees">
SELECT ....
</cfquery>
<cfreturn getEmployees />
</cffunction>
</cfcomponent>
cheers,
barneyb
----------------------------------------------------------
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).
CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm
An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]