Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi has anyone done this before?

Status
Not open for further replies.

ttrinh

MIS
Jan 21, 2002
93
0
0
AU
Hi
has anyone done this before?
I currently have an application that connects to an oracle database. I want to create a replica application of this for training purposes my client wants it to be linked off the production application. I already have a copy of the database (same name/same tables etc but in a different location) for testing purposes .
My question is is it possible to do this without adversely impacting any transactions in the production database?
and if so what do I need to consider ? as i can't see myself being able to test this on testing environment
Thanks
Thanh
 
Thanh,
Yes, I do this all the time. What do is create 2 different datasources -- 1 that points to the development schema and one that points to the production.

Then in my application.cfm file, I create 3 request variables that has the DSN Name, username and password.

e.g
application.cfm
<cfset request.appdsn = &quot;Dev_Dsn&quot;>
<cfset request.appuser = &quot;Dev_UserName&quot;>
<cfset request.apppassword = &quot;Dev_Password&quot;>

Then in all my cfquerys, I use this syntax:
<cfquery name=&quot;somename&quot; datasource=&quot;#request.appdsn#&quot; user=&quot;#request.appUser#&quot; password = &quot;#request.apppassword#&quot;>
etc.

This would be for the development setup -- If I want to point it to the production, all I have to do is change the 3 variables in the application.cfm -- the queries would then use the variables.


 
thanks for your reply
so then its ok to have 2 Application.cfm in the one application?

thanks
Thanh
 
CFDude,
or do I need 2 sets of this in the Application.cfm to point to the 2 different databases
what I have is this in Application.cfm
<cfset application.DS = &quot;BINS&quot;>
<cfset application.DB = &quot;ODBC&quot;>

But I still don't understand something .
If on button click it fires up the training app by calling index.cfm how does it know which database to update?
or do I have to make a copy of all the files and put a marker on it ,say training, and copy it into the same directory.
Thanh
 
You could have the user login using CF and depending on their login set the application.DS to either prod or dev.

IE - user logs in as <name> then the datasource variable is set to prod. If they log in as TRAINING they get dev.

One big thing is to make sure that it is obvious to them whether they're in prod or dev!

You don't want a user doing work in dev thinking its prod or vice versa.
 
Hi
I have created a subdirectory and copied all my cfms to its labelled as training. I change the
<cfset application.DS = &quot;BINS&quot;>
to
<cfset application.DS = &quot;BINS-Production&quot;> in the Application.cfm in the training subdirectory
(I am in test environment now, where I am using production database as my test database)
But I am still getting data updated in the original db and not in BINS-Production

is there something I have missed?
all other cfm files reference the datasource by #application.DS#

thanks
 
That should have worked. Unless you did not update your cfqueries to use the application.ds variable. The other thing to check is to make sure that your datasource is looking at the correct database. Can you post one of your cfquery's ?

What I highly suggest is to use a request variable instead. This is better than using an application variable in the application.cfm because it will be available to any custom tags. Plus you do not need to use <cflock> around reading/writing to request variables like you do with application variables.

use
<cfset request.DS = &quot;BINS&quot;>
<cfset request.DB = &quot;ODBC&quot;>

And of course, make sure you reference them in that format
<cfquery name=&quot;myquery&quot; datasource =&quot;#request.ds#&quot;>


If you are going to set it as an application variable, you also need to wrap it in a <cflock> anytime you read and write to it.
e.g
<cflock type=&quot;Exclusive&quot; scope=&quot;APPLICATION&quot; timeout=&quot;5&quot;>
<cfset application.DS = &quot;BINS&quot;>
<cfset application.DB = &quot;ODBC&quot;>
</cflock>

To read the variable, you still need to use cflock, but in a readonly type -- since this will be used in a cfquery, then, read it and set it as a temporary local variable and use that instead. That way you don't have to put a cflock around your whole query.

<cflock type=&quot;READONLY&quot; scope=&quot;APPLICATION&quot; timeout=&quot;5&quot;>
<cfset tmpDS = application.DS>
<cfset tmpDB = application.DB>
</cflock>

<cfquery name=&quot;MyQuery&quot; datasource=&quot;#tmpDS#&quot;>
query stuff
</cfquery>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top