Jason, I reckon you've made a pretty good start for your first day.
These things you're finding now will become second nature pretty
quickly.

I'm not sure if you have background in other programming, so perhaps i
can flesh out a little of what the others have said about the
Application.cfm file ..

You should have one in every site, even if it doesn't contain
anything, because ColdFusion will go searching for one every time you
call a page, and if it doesnt find one it will search and search
before giving up.   If you dont want to use one, give it an empty one
to find at the top level of your site.  It'll save a lot of processing
time on every page request.

However you should have an Applicatoin.cfm file  because it's very useful.

In your Application.cfm file, you should have the Application tag and
nowhere else,   that way you know you only have one <cfapplication
anywhere in the site.  If you have several of them,  you will get
confusion later on if something goes wrong, because you can not be
sure which application is current at the moment of the error.


Also in your Applicatoin.cfm file you can put all the environment
variables.  That way when you deploy your site to the production
server, all the things you have to change for that server are in the
one place.

For example, you have a DSN now called "MyDSN".  But when you put your
site up to the host, it's likely you will not be able to use that
name.  You might have to use a name more like "DSN765DLIJ" or who
knows what else.     All you have to do is have an Application.cfm
file you up load to the server with that DSN name in it, rather than
have to go right through your site changing every query, then when you
want to do work locally again changing them all back.

You can do the same with email addresses, colour settings, file paths,
mapping names,   all kinds of things.    Just have something like this
in your Application.cfm file:

<cfset application.dsn = "MyDSN" />

then in every query throughout the site,  put the dsn in like this;

<cfquery name="getnames" datasource="#application.dsn#">


Oh and Rick Root - It's more advanced than Jason is at the moment, and
I dont want to confuse him with unnecessary complications, but there
is at least one case where you can't use <cfqueryparam .....  if
you're going to use cachedwithin.   cfquery throws an error if you try
to use them both in the same query.

Jason, dont worry about that yet.  Cachedwithin is a way to cache
queries so they dont require a trip to the database every time.   For
your purposes at this stage, get in the habit  of using <cfqueryparam
on all your queries and you'll be ok.


Cheers
Mike Kear
Windsor, NSW, Australia
Adobe Certified Advanced ColdFusion Developer
AFP Webworks
http://afpwebworks.com
ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month




On 11/11/06, Rick Root <[EMAIL PROTECTED]> wrote:
> Jason T. Slack wrote:
> >
> > Now it tells me that my datasource is undefined:  Variable MYDSN is
> > undefined.
> >
> >>
> >> <cfquery name="ckCreds" datasource="#MyDSN#">
>
> If your DNS is named "MyDSN", then remove the # signs from around the
> name of the DSN.. it's not a variable.
>
> In my code, I often do something in the application.cfm like this:
>
> <cfset application.primarydb = "MyDSN">
>
> Then in my queries....
>
> <cfquery name="ckCreds" datasource="#application.primarydb#">
>
> That way, if you change your datasource name, you only have to change it
> in your application.cfm
>
> Rick
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:259991
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to