eXile has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I've got a problem with using DBI::Class::Loader, the next snippet of test code works OK on FreeBSD 4.8 with perl 5.8.2, but doesn't work on Sun OS 5.7 with perl 5.6.0.
use Class::DBI::Loader; my $loader = Class::DBI::Loader->new( dsn => "dbi:mysql:database=*******", user => "*******", password => "******", namespace => "BlaBla", ); my $class = $loader->find_class('MyTable'); print join (": " , $class->columns); my @obj = $class->retrieve_all(1); print $_->name foreach (@obj);
The error I get is:
Can't locate object method "set_db" via package "BlaBla::Contact" at / +usr/local/perl-5.6.0/lib/site_perl/5.6.0/Class/DBI/Loader/mysql.pm li +ne 48. Issuing rollback() for database handle being DESTROY'd without explici +t disconnect().
Where "Contact" is the first table that Mysql shows. I've looked at Class::DBI::Loader::mysql and the offending lines are:
no strict 'refs'; @{"$class\::ISA"} = qw(Class::DBI::mysql); $class->set_db( Main => @{ $self->_datasource } );
Last line triggers the error. Is this a perl5.6.0 problem ? can't execute a class-method on a class that is stored in a scalar or something? Is this solvable in perl5.6.0 ? thanks!

Replies are listed 'Best First'.
Re: DBI::Class::Loader problems
by perrin (Chancellor) on Dec 08, 2004 at 20:04 UTC
    I don't use Class::DBI::Loader, but I suggest you make sure that Class::DBI, Class::DBI::mysql, Ima::DBI, and DBD::mysql are all up-to-date before messing with your perl version.