Re: many2many

[prev] [thread] [next] [Date index for 2005/04/12]

From: William Ross
Subject: Re: many2many
Date: 17:23 on 12 Apr 2005
On 12 Apr 2005, at 15:43, Barry Dancis wrote:

> Hi Will--
>
>    Thanks, I got the many2many to work and I agree with you about the 
> naming conventions. I was using tables designed by someone else.
>
>    Now that I've got that working, I am back to getting cdbi factory 
> to work, but I can't seem to  get it initialized correctly. The code 
> has:
>
> use base 'Class::DBI::Factory';
> my $rebase = Class::DBI::Factory->new;
>   $rebase->set_db ({db_type => 'mysql',
>                 db_name => 'rebase:localhost',
>                 db_username => 'barry',
>                 db_password => '',
>                });
>   $rebase->use_classes (qw/Enzyme Site EnzymeSite/);
>   print "db_name: " . $rebase->db_name . "\n";
>
> but then I get the output:
>
> Use of uninitialized value in concatenation (.) or string at 
> C:\Development\Perl\try\Tisdall\try_many2many.pl line 26.
> db_name:

as your other message says, there's no db_name method. You should be 
getting grumbling from AUTOLOAD at that point.

> Set_db did not initialize the values for db name,  username and  
> password even thought I used the same values when I used 
> class::bdi->set_db.

if you use the factory to manage classes then it takes over the 
handling of database handles, in order that the same data class can be 
used to access more than one data table. it does this by inserting a 
db_Main method into each package, so some of the normal 
database-connection machinery is bypassed, and calls to set_db() in 
your data classes or base class will have no effect.

I don't know whether mysql on windows has special quirks, but this 
would normally work:

$rebase->set_db ({
	db_type => 'mysql',
	db_name => 'rebase',
	db_username => 'barry',
	db_password => '',
});

provided the account you describe has access. There's no need to 
specify the host or port unless they're odd, in which case db_host and 
db_port parameters will do it. You can sanity check the connection by 
looking at $rebase->dsn() or getting a handle from $rebase->dbh and 
inspecting it.

I assume this is just for testing and exploration purposes? otherwise 
I'd be recommending that you put it all in a configuration file 
instead.

?

will

many2many
Barry Dancis 16:46 on 11 Apr 2005

Re: many2many
William Ross 18:58 on 11 Apr 2005

Re: many2many
Tony Bowden 19:17 on 11 Apr 2005

Re: many2many
William Ross 19:38 on 11 Apr 2005

Re: many2many
Barry Dancis 14:43 on 12 Apr 2005

Re: many2many
William Ross 17:23 on 12 Apr 2005

Re: many2many
Barry Dancis 15:43 on 12 Apr 2005

Generated at 12:49 on 16 Apr 2005 by mariachi v0.52