We are using this function in our ResultSet.pm: sub exists { my ($self, $query) = @_;
return $self->search($query, { rows => 1, select => [\1] })->single; } Have a nice day Felix 2015-02-12 1:05 GMT+01:00 Charlie Garrison <garri...@zeta.org.au>: > Good morning, > > On 11/2/15 at 10:58 PM +0100, Ekki Plicht (DF4OR) <e...@plicht.de> wrote: > > >I am thinking of setting up a special resultset which contains only > >the key as a returned value by SELECT, but I am wondering if there is > >a faster method. > > Put a method in your ResultSet class, eg: > > sub key_exists { > my ($self, $key) = @_; > my $row = $self->find( $key ); > return $row ? 1 : 0; > } > > > Elsewhere: > > my $got_row = $schema->resultset('RSClass')->key_exists($key); > > > Charlie > > -- > Charlie Garrison <garri...@zeta.org.au> > github.com/cngarrison metacpan.org/author/CNG > > O< ascii ribbon campaign - stop html mail > http://www.ietf.org/rfc/rfc1855.txt > > > _______________________________________________ > List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class > IRC: irc.perl.org#dbix-class > SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ > Searchable Archive: > http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk >
_______________________________________________ List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk