[Dbix-class] Class::DBI vs DBIx and CDBICompat

Matt S Trout dbix-class at trout.me.uk
Fri Jun 23 17:16:46 CEST 2006


Steven Mackenzie wrote:
> Hello,
> 
> I stumbled upon this piece of documentation:
> http://search.cpan.org/~jrobinson/DBIx-Class-0.06003/lib/DBIx/Class/CDBICompat.pm
> 
> Which suggests that I can start using DBIx::Class simply my making this
> change to my Class::DBI code:
> 
> # In DBBase.pm
> #use base qw( Class::DBI ); # currently using 3.0.6 from ActiveState ppm.
> use base qw/DBIx::Class/; # currently 0.6000 from ActiveState pmm

Get 0.06003 from CPAN. ActiveState can't package for shit.

> __PACKAGE__->load_components( qw/CDBICompat Core DB/ );
> 
> This seemed worth a try, to see if my app might start making fewer calls
> to the DB perhaps :-)
> 
> However, I get this error at startup:
> Can't locate object method "set_db" via package "DBBase" at
> C:\xyz\InitDatabase.pm line 33.
> 
> In my application I make the call to the Class::DBI method set_db via my
> DBBase.pm module, like this:
>   DBBase->set_db
>   (
>     'Main',
>     $dsn, # passed in by caller
>     $username,
>     $password,
>     {RaiseError => 1,
>      AutoCommit => 0, # Don't autocommit transactions
>      unicode => 1}
>   );
> 
> It seems that this isn't part of the emulated funcionality, and so I
> have two questions:
> 
> How can I set the DBIx::Class DB connection?

Why can't you just call ->connection ?

> Is there any possible reduction in DB traffic to be gained by using
> DBIxC over CDBI?

Huge, but you won't get most of it without converting over to native DBIC 
since a lot of the advantages require use of DBIx::Class APIs - CDBI simply 
isn't capable of things we tend to take for granted.

-- 
      Matt S Trout       Offering custom development, consultancy and support
   Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Dbix-class mailing list