X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FResultSet.pm;h=4e69104bc9479ff28057407c0633e9e365f18437;hb=0a3c5b435bb12d9cf11a403cb2933d106e8a0374;hp=999f322ea87578048fb5ee68dbba888500484d02;hpb=9a1908440a98f0721dede3a95b9700d2e34af10a;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index 999f322..4e69104 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -58,9 +58,9 @@ sub new { } my $new = { source => $db_class, - cols => $attrs->{cols} || [ $db_class->_select_columns ], + cols => $attrs->{cols}, cond => $attrs->{where}, - from => $attrs->{from} || $db_class->_table_name, + from => $attrs->{from}, count => undef, pager => undef, attrs => $attrs }; @@ -69,6 +69,34 @@ sub new { return $new; } +=item search + +Runs a search against the current resultset. + +=cut + +sub search { + my $self = shift; + + my $attrs = { %{$self->{attrs}} }; + if (@_ > 1 && ref $_[$#_] eq 'HASH') { + $attrs = { %{ pop(@_) } }; + } + + my $where = (@_ == 1 || ref $_[0] eq "HASH" ? shift: {@_}); + if (defined $where) { + $where = (defined $attrs->{where} + ? { '-and' => [ $where, $attrs->{where} ] } + : $where); + $attrs->{where} = $where; + } + + my $rs = $self->new($self->{source}, $attrs); + + return (wantarray ? $rs->all : $rs); +} + + =item cursor Return a storage driven cursor to the given resultset.