Yep, you're pretty much dead on.  There's no reason you can't use
application.dsn directly, but you're definitely better off passing it
into init(), storing it in the variables scope, and using it from
there.  I wouldn't bother with the check for the database in init for
two reasons:

1) your application shouldn't be initialized very often, so that check
won't run very often.
2) you'll need to handle dead database connections on every query
anyway, so just handle it there to save yourself some work.

cheers,
barneyb

On 6/24/05, Stephen Adams <[EMAIL PROTECTED]> wrote:
> Hi,
>  
>  I am trying to run a query and I'm trying to get the application.DSN I have
> set in my application.cfm file, I can't use <cfquery name="query"
> datasource="#application.dsn#"> should I be using variables.DSN or is better
> practice to create a init() function (as a constructor) and pass the DSN
> details as part of the init() function. Which should be accessible to the
> queries in my CFC. I could also check if I have a connection to the database
> in this init function and throw an error if no connection is found.
>  
>  What do you guys think?

-- 
Barney Boisvert
[EMAIL PROTECTED]
360.319.6145
http://www.barneyb.com/

Got Gmail? I have 50 invites.


----------------------------------------------------------
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]


Reply via email to