[thelist] CF: Determining which DB used.

Raymond Camden jedimaster at macromedia.com
Wed Sep 12 07:11:20 CDT 2001

Well, remember that CF uses a datasource to tell what DB to hit. If you
move from SQL Server to MySQL and keep the same datasource name, you
don't have to change anything! (Major caveat to follow.) Another option
- keep the DSN as an application variable:

	application.dsn = "SQLServer_FooMama";

and use the var in your queries:
	<CFQUERY NAME="GetIt" DATASOURCE="#Application.DSN#">

then you only need to change one file if you change your DSN.

Major Caveat: Just changing the backend is ONLY safe if you have used
SQL statements that work in both the old DB and the new DB. There are
things you can do to ensure that this won't be a problem. You can also
do things like abstracting your db calls to custom tags, which is what
Spectra does. I did this on a project recently where I had to switch
databases... not products, but structures, and having my db calls in one
set of tags made migration _very_ easy.

Raymond Camden, Principal Spectra Compliance Engineer for Macromedia

Email    : jedimaster at macromedia.com
Yahoo IM : morpheus

"My ally is the Force, and a powerful ally it is." - Yoda 

> -----Original Message-----
> From: thelist-admin at lists.evolt.org 
> [mailto:thelist-admin at lists.evolt.org] On Behalf Of Frank
> Sent: Wednesday, September 12, 2001 4:37 AM
> To: thelist at lists.evolt.org
> Subject: [thelist] CF: Determining which DB used.
> Hi,
> The apps I write are cross platform, thus different DBs come into 
> play. Access or SQL 7 on PC, and MySQL on Linux. Is there a way of 
> automatically determining what database I'm using without having to 
> resort to creating a global variable and changing it every time I 
> move my app? It's a little thing that would make the transitions 
> smoother.
> -- 
> Some are born great. Some achieve greatness.
> Both are excellent contacts to keep in your Rolodex.
>                                    -- Bob Patterson.
> Frank Marion                      Framar Studios
> frank at framarstudios.com           http://www.framarstudios.com
> ---------------------------------------
> For unsubscribe and other options, including
> the Tip Harvester and archive of TheList go to: 
http://lists.evolt.org Workers of the Web, evolt ! 

More information about the thelist mailing list