[Dbix-class] Is this the canonical way to do this?

John Napiorkowski jjn1056 at yahoo.com
Fri Jun 9 07:00:44 CEST 2006


I probably shouldn't name name variable "$video_rs"
since it could cause confusion.  I know it took me a
while to figure out the whole resultset versus row
deal.  Now I don't think about it so much it's easy to
get sloppy.  -john

--- Matt S Trout <dbix-class at trout.me.uk> wrote:

> 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/ +
> 
> _______________________________________________
> List:
>
http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
> Wiki: http://dbix-class.shadowcatsystems.co.uk/
> IRC: irc.perl.org#dbix-class
> SVN:
>
http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Dbix-class mailing list