Re: Several databases from the same script

[prev] [thread] [next] [Date index for 2004/06/03]

From: Tony Bowden
Subject: Re: Several databases from the same script
Date: 07:25 on 03 Jun 2004
On Thu, Jun 03, 2004 at 02:24:50AM +0300, Gabor Szabo wrote:
> I needed to access them from the same script basically at the same time.
> The best solution I could come up so far is the following.
> Any corrections, ideas are welcome.

The problem you have here is that this information is class data, so if
you do

init($db1)
my $obj1 = create(..);
init($db2)
my $obj2 = create(..);

And then try to do anything with obj1, it will be expecting to operate
on db2.

The more correct approach here is to have a distinct subclass for each
database you use.

You can then make your 'table' class contain all the abstract data about
the schema, and have a subclass for each database that it's going to
be in.

> ps. I could not log in the web site even after receiving the password
> by e-mail. It kept saying it cannot set cookie and I should configure
> my Navigator to enable cookies.  I am using Opera and they are enabled.

Which web site? The list archives or the wiki? If it's the list archive,
then this is just a standard Sympa install, so you may want to check
with the Sympa people if this is a known problem.

Thanks,

Tony

> 		$current_dbh = $dbh{$dsn} = DBI->connect_cached($dsn, $username, $password,
> 					{
> 						# defaults of Class::DBI
> 						RaiseError                  => 1,
> 						AutoCommit                 => 0,
> 						PrintError                 => 0,
> 						Taint                       => 1,
> 						RootClass                   => "DBIx::ContextualFetch",
> 					});

PS, if you're using the current Class::DBI (which the RootClass would
imply) you can just use $class->_default_attributes to get the current
CDBI / Ima::DBI default attributes.

Several databases from the same script
Gabor Szabo 23:24 on 02 Jun 2004

Re: Several databases from the same script
Tony Bowden 07:25 on 03 Jun 2004

Re: Several databases from the same script
Branislav Zahradnik 08:32 on 03 Jun 2004

Re: Several databases from the same script
Tony Bowden 09:16 on 03 Jun 2004

Re: Several databases from the same script
Tony Bowden 10:02 on 07 Jun 2004

Re: Several databases from the same script
Branislav Zahradnik 13:26 on 07 Jun 2004

Generated at 11:34 on 01 Dec 2004 by mariachi v0.52