[Dbix-class] Is this the canonical way to do this?
Matt S Trout
dbix-class at trout.me.uk
Thu Jun 8 17:05:02 CEST 2006
John Napiorkowski wrote:
> Looks like I was having some sort of mental block the
> other night. I got the following to work properly:
>
> my $video_rs = $self->find({video_id=>$video_id});
> return ( defined($video_rs) ? 1 : 0 );
>
> and it did what I wanted.
>
> I have to specify the key name in find since my table
> has multiple primary keys. I've also found that since
> ->find works for any column marked as unique it has
> really improved my thinking about my table designs,
> since I am more careful to normalize properly to get
> more truly unique columns. So in this way I am sure
> DBIx has improved my table designs.
Note that find is always a 0 or 1 record query (or should be), so it returns a
row object of the appropriate class, not a resultset.
--
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