Re: many2many
[prev]
[thread]
[next]
[Date index for 2005/04/12]
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