[Dbix-class] How to use DBIx::Class on a view

Matt S Trout dbix-class at trout.me.uk
Wed Nov 16 18:18:34 CET 2005


On Wed, Nov 16, 2005 at 04:43:09PM +0000, Nigel Metheringham wrote:
> On Tue, 2005-11-15 at 20:06 +0000, Matt S Trout wrote:
> > I reckon your primary key is (date,bs_group,feature).
> 
> That seems right...
> 
> However that gives me another issue.  bs_group and feature are keys into
> other tables, so I wanted to make them has_one relationships, which gave
> me a class content like this.... (slightly shortened):-
>         __PACKAGE__->table('group_date_feature_map');
>         __PACKAGE__->add_columns(qw/date bs_group feature count/);
>         __PACKAGE__->set_primary_key(qw/date bs_group feature/);
>         
>         # set up the relationships
>         __PACKAGE__->belong_to(bs_group => 'App::M::Database::BsGroup');
>         __PACKAGE__->belong_to(feature => 'App::M::Database::Feature');

I'm not sure you're using find how you think you are. Try

$class->find($date, $bs_g, $feature);

or

$class->find({ date => $date, bs_group => $bs_g, feature => $feature });

Find is designed to retrieve a single record by PK - if you just want to get
back a set of results matching a given condition, use ->search

-- 
     Matt S Trout       Specialists in Perl consulting, web development, and
  Technical Director    UNIX/Linux systems architecture and automation. Mail
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