From: Simon Cozens Date: Sat, 31 Jan 2004 16:18:42 +0000 (+0000) Subject: Use abstract search instead; more flexible. X-Git-Tag: 2.10~327 X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=59477ddf266ae5c48c4dcff3466b775aa1b6a215;p=maypole.git Use abstract search instead; more flexible. git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@35 48953598-375a-da11-a14b-00016c27c3ee --- diff --git a/lib/Apache/MVC/Model/CDBI.pm b/lib/Apache/MVC/Model/CDBI.pm index 88c1d52..4d6339d 100644 --- a/lib/Apache/MVC/Model/CDBI.pm +++ b/lib/Apache/MVC/Model/CDBI.pm @@ -3,6 +3,7 @@ use base qw(Apache::MVC::Model::Base Class::DBI); use Lingua::EN::Inflect::Number qw(to_PL); use Class::DBI::AsForm; use Class::DBI::FromCGI; +use Class::DBI::AbstractSearch; use CGI::Untaint; use strict; @@ -63,9 +64,13 @@ sub adopt { sub search :Exported { my ($self, $r) = @_; my %fields = map {$_ => 1 } $self->columns; - my %values = map { $_ => $params{$_} } - grep { $params{$_} and $fields{$_} } keys %{$r->{params}}; - $r->objects([ %values ? $self->search_like(%values) : $self->retrieve_all ]); + my $oper = "like"; # For now + my %params = %{$r->{params}}; + my %values = map { $_ => {$oper, $oper eq "like" ? "%".$params{$_}."%" + :$params{$_} } } + grep { $params{$_} and $fields{$_} } keys %params; + + $r->objects([ %values ? $self->search_where(%values) : $self->retrieve_all ]); $r->template("list"); $r->{template_args}{search} = 1; }