Purdy has asked for the wisdom of the Perl Monks concerning the following question:
So then I create a script like so:
$database = "foo"; require '/home/share/jdb.cgi'; # now I can do whatever with $dbh..
This may not seem like the best way to do it (and may not be ;)), but I have two web servers & two different directories and I don't want to work on CGI scripts in one, test and get it ready and then move it over to production and have to remember to switch something (such as if I had a subroutine to change a parameter).
I hope this makes sense so far. Ok, so the problem is whenever my script on the development server updates the database, it's updating the production database server (not the DSN it was given, which would be port 3308, a development db server that has a different datadir, etc). I debugged & found that the DSN for the development server was being provided correctly for a script that was within the "site-dev" path ... boggles me as to what could be wrong.
Thanks in advance for any help! :)
Jason
Here's the script:
use DBI; my ($package, $filename) = caller; #my ($dsn); # if it's the dev site, return the Dev DSN, otherwise, return # the production DSN. if ($filename =~ /sites-dev/) { # it's the dev site $dsn = "DBI:mysql:database=$database;port=3308"; } else { # it's the production site $dsn = "DBI:mysql:database=$database;port=3306"; } $dbh = DBI->connect($dsn, "perlscript", "passboy"); 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Centralized DSN Switch Script (MySQL)
by chromatic (Archbishop) on Nov 02, 2001 at 02:56 UTC | |
|
Re: Centralized DSN Switch Script (MySQL)
by Purdy (Hermit) on Nov 02, 2001 at 03:33 UTC | |
by Anonymous Monk on Nov 02, 2001 at 12:26 UTC | |
by lucs (Sexton) on Nov 02, 2001 at 12:33 UTC | |
|
Re: Centralized DSN Switch Script (MySQL)
by lucs (Sexton) on Nov 02, 2001 at 02:16 UTC | |
by Purdy (Hermit) on Nov 02, 2001 at 02:26 UTC | |
by lucs (Sexton) on Nov 02, 2001 at 03:05 UTC | |
by Purdy (Hermit) on Nov 02, 2001 at 03:09 UTC | |
|
Re: Centralized DSN Switch Script (MySQL)
by Purdy (Hermit) on Nov 02, 2001 at 18:56 UTC |