Class-DBI-Plugin-CountSearch
view release on metacpan or search on metacpan
lib/Class/DBI/Plugin/CountSearch.pm view on Meta::CPAN
my (@cols, @vals);
my $search_opts = @args % 2 ? pop @args : {};
while (my ($col, $val) = splice @args, 0, 2) {
my $column = $class->find_column($col)
|| (List::Util::first { $_->accessor eq $col } $class->columns)
|| $class->_croak("$col is not a column of $class");
push @cols, $column;
push @vals, $class->_deflated_column($column, $val);
}
my $frag = join " AND ",
map defined($vals[$_]) ? "$cols[$_] $search_type ?" : "$cols[$_] IS NULL",
0 .. $#cols;
defined($frag) && $frag ne '' and
$frag = " WHERE $frag";
return $class->sql_count_search($frag)->select_val(@vals);
};
}
=head1 AUTHOR
Todd Holbrook, E<lt>tholbroo@sfu.caE<gt>.
Plugin importing and _do_count_search borrowed from Tony Bowden's Class::DBI
and Class::DBI::Plugin::RetrieveAll.
( run in 0.575 second using v1.01-cache-2.11-cpan-364913b4093 )