[Catalyst] Catalyst::Model::CDBI

Toby Corkindale tjc at wintrmute.net
Thu Oct 6 18:53:21 CEST 2005


On Thu, Oct 06, 2005 at 05:04:40PM +0200, Jesper Krogh wrote:
> > On 10/6/05, Jesper Krogh <jesper at krogh.cc> wrote:
> > You just add a line like:
> > __PACKAGE__->columns(Essential => qw/id nick name cdate/);
> >
> > to your model package, and then on default only the listed columns will be
> > loaded from the database. Please read the 'LAZY POPULATION' part of CDBI
> > documentation for further explanations
> 
> Yes.. but doesn't that solutoin assumes that I have a "model" class?
> I dont, since it uses Class::DBI::Loader to load the database model.

Ah, but you can still create Model classes to extend the automagically created
ones.

ie. if Class::DBI::Loader is creating a Catalyst class called
Foo::M::CDBI::Bar, then go into $lib/Foo/M/CDBI and vim Bar.pm

------8<--------
Package Foo::M::CDBI::Bar;
use strict;
use warnings;
__PACKAGE__->columns(Essential => qw/id nick name cdate/);
1;
------>8--------

The DB autoloading is still done, but that package is autoloaded and used to
extend the options/features.

tjc

-- 
Turning and turning in the widening gyre/The falcon cannot hear the falconer;
Things fall apart, the centre cannot hold/Mere anarchy is loosed upon the world
(gpg --keyserver www.co.uk.pgp.net --recv-key B1CCF88E)



More information about the Catalyst mailing list