I don't think there should be a problem with Apache::DBI but I had
previously experienced things like this when storing connection info in
a global variable that has the same name across multiple virtual
servers. As a solution, one can create an autohandler in the main Mason
folder that configures all the databases for all possible websites as a
hash with the server name as part of the key:
# Server Configuration Template - repeat for each virtual server
# Hostname of the server
# $this_server="www.myserver.com";
# DBI access-string for XYZ database
# $globals{$this_server . '_dbXYZ'}="DBI:mysql:XYZ";
# DB username and password
# $globals{$this_server . '_dbuser'} = "abc";
# $globals{$this_server . '_dbpass'} = "def";
# DBI error flags
# $globals{$this_server . '_dbconfig'} = {PrintError=>0,RaiseError=>1};
and then in the <init> part of the code
$dbh = DBI->connect($globals{$ENV{'SERVER_NAME'} .
'_dbXYZ'},$globals{$ENV{'SERVER_NAME'} .
'_dbuser'},$globals{$ENV{'SERVER_NAME'} .
'_dbpass'},$globals{$ENV{'SERVER_NAME'} . '_dbconfig'});
This requires that $globals is set to be a Mason global in the apache.conf.
Matt Grommes wrote:
> I've recently added a new site to my server, both now running Mason. The
> problem is that I'll get errors on the first site and when I look at the
> log, it'll say it's trying to use the second site's database. The issue
> as I see it (if I'm wrong please correct me) is that since both sites
> use Apache::DBI, it's sharing the database connections between the two
> sites. This seems like it's probably a common issue so is there a good
> fix for this? Thanks.
>
> -- Matt Grommes --
> www.unreads.com
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Mason-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mason-users
>
>
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Mason-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mason-users